crontab配置shell实现后台进程不间断运行

检测get_report_no.php进程是否一直在运行

#!/bin/bash  
PROC=`ps -ef |grep get_report_no.php|grep -v grep|wc -l`
if [ ! $PROC -eq 1 ];then
    ps -ef |grep get_report_no.php|grep -v grep|awk '{print $2}'|xargs kill -9
    php /data/server/www/scrap/get_report_no.php &
fi

每隔10分钟运行此脚本
*/10 * * * * /bin/sh /opt/check_get_report_no.sh
原文地址:https://www.cnblogs.com/shansongxian/p/9760648.html