shell判断脚本是否运行

判断`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
```

    A+
发布日期:2021年04月13日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: