每隔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

  

做个笔记。

原文地址:https://www.cnblogs.com/chenglee/p/9712034.html