linux查看进程是否存在,不存在则重启

ps -ef | grep 程序名| grep -v grep  | wc -l
cd $(dirname $0)

source ~/.bash_profile


count=`ps -ef | grep "nginx: master process" | grep -v grep | wc -l`


if [ $count -eq 0 ];then
        /data/openresty/nginx/sbin/nginx
fi
原文地址:https://www.cnblogs.com/linn/p/4481663.html