每隔3天自动重启进程

这个小玩意是帮同事写的.

#!/bin/bash
while :
do
	/bin/sleep 3d
	time=$(date "+%Y-%m-%d %H:%M:%S")
	echo "****$time****"
	PID=`ps -ef|grep mysql|grep -v grep|grep -v PPID|awk '{ print $2}'`
	if [ ! -n "$PID" ]; then
		echo "not process"
	else
		echo "is process"
		/usr/bin/kill -9 $PID
		#/opt/mysql/start.sh
		echo "reboot success"
	fi

done

  

做个笔记。

posted @ 2018-09-27 11:07  扶苏公子x  阅读(359)  评论(0)    收藏  举报