1、判斷進程是否掛掉code
#!/bin/sh ps -ef | grep httpd | grep -v grep if [ $? -ne 0 ] then echo "start process......" else echo "runing......" fi
2、判斷進程是否掛掉,若是掛掉需重啓進程
#!/bin/sh while true;do ps -ef | grep httpd | grep -v grep if [ $? -ne 0 ] then echo "start process......" service httpd start else echo "runing......" fi sleep 20 done