# restart.sh

old_pid=$(ps ax|grep Service.py|grep -v grep|awk '{print $1}') echo "old_pid=${old_pid}" if [ -z $old_pid ];then echo "Process Non-existent !" echo "Starting Process...." nohup python /home/Service.py >/dev/null 2>&1 & else kill -9 ${old_pid} mid_pid=$(ps ax|grep Service.py|grep -v grep|awk '{print $1}') if [ -z ${mid_pid} ];then echo "Process Close Success !" echo "Start Restarting....." nohup python /home/Service.py >/dev/null 2>&1 & else echo "Process Close Fail !" exit 1 fi fi new_pid=$(ps ax|grep Service.py|grep -v grep|awk '{print $1}') if [ -z ${new_pid} ];then echo "Restart Fail !" else echo "Restart Success !" echo "new_pid=${new_pid}"

 

相关文章:

  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
猜你喜欢
  • 2022-12-23
  • 2021-12-15
  • 2021-06-27
  • 2022-12-23
  • 2022-01-21
  • 2021-12-01
  • 2021-10-30
相关资源
相似解决方案