检测进程,判断是否需要重启
while true
do
ps aux | grep ProgramName | grep -v grep //-v 在文档中过滤掉包含有grep字符的行
if [ $? -eq 0 ];then //$? 判断上个程序退出状态码, 0 默认成功
#找到了
sleep 5
else
#没找到,启动
fi
done
//$n $1 the first parameter,$2 the second...
//$# The number of command-line parameters.
//$0 The name of current program.
//$? Last command or function's return value.
//$$ The program's PID.
//$! Last program's PID.
//$@ Save all the parameters.