#!/bin/bash while true do process=`ps aux | grep name_abc | grep -v grep`; if [ "$process" == "" ]; then cd /home/wwwroot/server/protected/soa; php server.php echo "server restart"; else echo "server ok"; break; fi done
然后在crontab里加入检测即可 crontab -e
*/1 * * * * /data/script/server.sh