1. 程式人生 > >用shell腳本監控進程是否存在 不存在則啟動的實例

用shell腳本監控進程是否存在 不存在則啟動的實例

art ces yii run 存在 amp ... bin proc

用shell腳本監控進程是否存在 不存在則啟動的實例:

#!/bin/sh
ps -fe|grep processString |grep -v grep
if [ $? -ne 0 ]
then
echo "start process....."

nohup php yii test/action &

else
echo "runing....."
fi
#####
processString 表示進程特征字符串,能夠查詢到唯一進程的特征字符串
0表示存在的
$? -ne 0 不存在,$? -eq 0 存在

用shell腳本監控進程是否存在 不存在則啟動的實例