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

 

相关文章:

  • 2021-06-21
  • 2021-09-06
  • 2022-12-23
  • 2021-12-08
  • 2021-09-21
  • 2022-01-04
  • 2022-12-23
  • 2022-03-11
猜你喜欢
  • 2021-08-25
  • 2022-03-13
  • 2021-12-20
  • 2022-12-23
  • 2021-08-06
  • 2021-10-21
  • 2022-12-23
相关资源
相似解决方案