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

腳本監(jiā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進程

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

  

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

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