当前位置:首页 > IT技术 > 系统服务 > 正文

脚本监控进程自动拉起进程
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/

开通会员,享受整站包年服务立即开通 >