crontab -e
*/3 * * * * /data/log_realtime/check.sh > /data/log_realtime/check.log 2>&1 1 0 1 * * /data/jx3log_import_realtime/shutdown.sh
说明:每3分钟检查一次进程是否存在,每个月1号0点1分杀掉进程,重启
check.sh
cd $(dirname $0)
source ~/.bash_profile
SYSTEM_TIME=`date '+%Y-%m-%d %T'`
count=`ps -ef | grep "python /data/script/realtime.py" | grep -v grep | wc -l`
if [ $count -eq 0 ];then
echo $SYSTEM_TIME >> /data/script/check.log
nohup python /data/script/realtime.py > log.txt 2>&1&
fi
shutdown.sh
PROCESS=`ps -ef|grep "python watch_file_temp.py"|grep -v grep|grep -v PPID|awk '{ print $2}'` for i in $PROCESS do echo "Kill the $1 process [ $i ]" kill -9 $i done