|
|
我参考网上的脚本,自己改写了一个。但是不知道为什么无效。貌似if不对?- ipv4=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
- EMAIL_TO="[email protected]"
- nd=`pgrep -f nginx | wc -l`
- if [ $nd -eq "0" ];
- then
- /usr/local/nginx/sbin/nginx
- /usr/local/php/sbin/php-fpm start
- echo -e "Server IP is : $ipv4 " | mail -s "The nginx program is Dead" $EMAIL_TO
- else
- echo -e "[`date "+%Y-%m-%d %T"`] the program is running" >>/root/nginxd.log
- fi
复制代码 当关闭nginx进程的时候,执行pgrep -f nginx | wc -l显示是0.但是直接执行脚本却无效。求救。。。
|
|