You need to install yum install stat crontabs first (this example is under centos system)
#!/bin/bash
#Shell
##Monitor according to the modified file time##
c -l /tmp/log.txt | awk '{ print $5 }'` //Get the file size
filetime=`stat /tmp/q | tail -1 | awk '{print $2,$3}'` //Get the file update time
test=`cat /tmp/log. txt` // View the file content
if [ $content == "0" ]; then
elif [ "$filetime" == "$ test "]; then // If the file is not modified, then execute
kill nginx
/Home/nginx_server/nginx/sbin/nginx
else // tmp/log.txt
fi
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the SHELL script to implement automatic restart of service downtime monitoring, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.