怎么做企业销售网站,如何在线上注册公司,标准型网站建设开发,苏州建筑公司有哪些检查Python程序未运行则重新运行 entity_program定时杀掉进程重新运行 match_program定时检查是否运行#xff0c;未运行则启动 (注意echo时间时#xff0c;date和中间要有空格) #!/bin/bash# 检测的Python程序名称
entity_programentity.py
match_program…检查Python程序未运行则重新运行 entity_program定时杀掉进程重新运行 match_program定时检查是否运行未运行则启动 (注意echo时间时date和中间要有空格) #!/bin/bash# 检测的Python程序名称
entity_programentity.py
match_programmatch.py# 获取Python进程的PID
PID$(pgrep -f $entity_program)
if [[ -n $PID ]]
thenecho $(date %Y-%m-%d %H:%M:%S) Python程序 $entity_program 在运行中.正在killkill $PIDecho killed, starting ...# cd /home/xxx/match/service# /opt/conda/envs/match/bin/python3.7 entity.py /dev/null 21 echo 已启动
elseecho $(date %Y-%m-%d %H:%M:%S) Python程序 $entity_program 没有在运行正在重启...# 重启Python程序的命令例如# cd /home/xxx/match/service# /opt/conda/envs/match/bin/python3.7 entity.py /dev/null 21 echo 已启动
fiif pgrep -f $match_program /dev/null
thenecho $(date %Y-%m-%d %H:%M:%S) Python程序 $match_program 在运行中.
elseecho $(date %Y-%m-%d %H:%M:%S) Python程序 $match_program 没有在运行正在重启...# 重启Python程序的命令例如# cd /home/xxx/match/service# /opt/conda/envs/match/bin/python3.7 match.py /dev/null 21 echo 已启动
fi50 11 * * * /home/xxx/check/run.sh /home/xxx/check/logfile.log 21
30 0 * * * /bin/bash /data/dgcy_code/dist/algorithm_check.sh /data/dgcy_code/dist/algorithm_check.log 21 # 完整路径数组
programs(/data/dgcy_code/dist/python_new)# 循环读取数据中的文件名
for pg in ${programs[]}
do# 获取文件名filename$(basename $pg)pathname$(dirname $pg)PID$(pgrep -f $filename)if [[ -n $PID ]]thenecho $(date %Y-%m-%d %H:%M:%S) Python程序$filename在运行中.正在killkill $PIDecho killed, starting ...cd $pathnamenohup ./$filename /dev/null 21 echo 已启动elseecho $(date %Y-%m-%d %H:%M:%S) Python程序$filename没有在运行正在重启...# 重启Python程序的命令例如cd $pathnamenohup ./$filename /dev/null 21 echo 已启动fi
done