You need to install the Yum install stat Crontabs (This example is under the CentOS system)
#!/bin/bash
#Shell
# #根据修改文件时间进行监控 # #
C-l/tmp/log.txt | awk ' {print $} '//Get file size
Filetime= ' stat/tmp/q | Tail-1 | awk ' {print $2,$3} '//Get file update time
test= ' cat/tmp/log.txt '//view file contents
if [$content = = "0"];then//If the file size is 0
echo $filetime >/tmp/log.txt
elif ["$filetime" = = "$test"];then//If the file is not modified then execute
Killall Nginx
/home/nginx_server/nginx/sbin/nginx
else//If you modified the execution to write the time that the file was modified to log
echo $filetime >/tmp/log.txt
Fi
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the shell script to implement service outage monitoring automatic restart, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.