當(dāng)前位置:首頁 > IT技術(shù) > 系統(tǒng)服務(wù) > 正文

腳本監(jiān)控進(jìn)程自動拉起進(jìn)程
2021-11-16 11:37:54

#!/bin/bash 

process_name=app-0.0.1-SNAPSHOT.jar

while [ 1 ]
do

  time=`date`
  serverpid=`ps -ef|grep $process_name|grep -v grep|awk '{print $2}'`

  if [  "$serverpid"  ];then


       echo   $time" $process_name  process is running , pid is  $serverpid " >> /tmp/app_process_monitor.log 

  else
      echo    $time" $process_name  process is not running, now starting ..."  >> /tmp/app_process_monitor.log

      cd /home/app && sh app_start.sh start

  fi 

  sleep 60 

done 

  

啟動monitor進(jìn)程

sh /home/app_process_monitor.sh & > /dev/null 2>&1

  

本文摘自 :https://www.cnblogs.com/

開通會員,享受整站包年服務(wù)立即開通 >