Due to Nginx's outstanding performance, more and more web servers use Nginx. Although nginx is great, what if it crashes? We 'd better write a script for monitoring. If nginx fails, the system restarts automatically. Of course, before giving the script, make a few assumptions: the nginx directory is/usr/local/n... due to Nginx's outstanding performance, more and more web servers use Nginx. Although nginx is great, what if it crashes? We 'd better write a script for monitoring. If nginx fails, the system restarts automatically.
Of course, before giving the script, make a few assumptions: the nginx directory is/usr/local/nginx/, and the pid conf is under the corresponding default directory. The instance script is as follows:
If [! -F $ pidFile]; then
$ NginxBin-c $ confFile
Fi
The above script does not work. you need to add it to the system scheduled task. Crontab is required at this time. Here is a tip: The minimum crontab time is minute. our monitoring script cannot be in minutes. if we run the script every five seconds, what should we do? Assume that the above script is saved as/root/. bin/webmonitor. sh and edit crontab as follows:
Through the above operations, the monitoring script can basically run. Of course, you can continue to expand, how to monitor php and so on
For more information about crontab usage, see previous blog: crontab command summary.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service