#!/bin/bashfunction stop(){ PROCESS_LIST=$(ps -ef|grep nginx |egrep -v "grep|$0"|awk '{print $2}') for process in $PROCESS_LIST do kill -9 $process &>/dev/null done echo "nginx 服务关闭"}function start(){ cd /data/sbin/ && ./nginx &> /dev/null # /data/sbin为nginx启动文件目录,./nginx为启动nginx服务 echo "nginx 服务启动"}function status(){ ps_number=$(ps -ef|grep nginx|egrep -v "grep|$0"|wc -l ) if [[ $ps_number -ne 0 ]] then echo "nginx [running]" else echo "nginx [not running]" fi}function main(){ case $1 in stop) stop ;; start) start ;; restart) stop sleep 2 start ;; status) status ;; esac}main $@
nginx服务启动脚本
时间:2023-06-23
相关推荐