Home > Backend Development > PHP Tutorial > SHELL script implements service downtime monitoring and automatic restart

SHELL script implements service downtime monitoring and automatic restart

WBOY
Release: 2016-08-08 09:21:03
Original
2291 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template