shell判断脚本是否运行

发布时间:2021-04-13 15:22:39 阅读:1366次

判断nginx是否运行

#!/bin/bash
name='nginx'
num=$(ps -ef|grep $name |grep -vc grep)
if [ $num -ge 1 ]; then
    echo "$name is running!"
else
    echo "$name is not running!"
fi

判断php脚本是否运行

#!/bin/bash
name='abc/cdn/run'
num=$(ps -ef|grep $name |grep -vc grep)
echo $num
if [ $num -ge 1 ]; then
    echo "$name is running!"
else
    echo "$name is not running!"
    /app/php7.2/bin/php /app/www/cron/index.php abc/cdn/run &
fi

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:shell判断脚本是否运行 出自老鄢博客 | 欢迎分享