Linux 检查进程是否执行,没有则执行,然后 用 crontab 定时执行,就可以对进程进行监控了
#!/bin/sh
ps aux|grep "craw_des.py"|grep -v grep #grep 正则匹配 字符串,grep -v grep --忽略包含grep 的字符串if [ "$?" != "0" ];then
echo "no craw_des.py , run it now"
/usr/bin/python /seek/craw/craw_des.py &
else
echo "craw_des.py is running..."
fi
ps aux|grep "craw_des2.py"|grep -v grep
if [ "$?" != "0" ];then
echo "no craw_des2.py , run it now"
/usr/bin/python /seek/craw/craw_des2.py &
else
echo "craw_des3.py is running..."
fi
ps aux|grep "craw_des3.py"|grep -v grep
if [ "$?" != "0" ];then
echo "no craw_des3.py , run it now"
/usr/bin/python /seek/craw/craw_des3.py &
else
echo "craw_des3.py is running..."
fi