Monitor php-fastcgi Timeout restart script in Linux

Source: Internet
Author: User

Scripting code

The code is as follows Copy Code
if [-e/var/lock/subsys/502]
Then
Killall-9 Curl 2>/dev/null
Killall-9 PHP-FPM 2>/dev/null
Killall-9 php-cgi 2>/dev/null
Service PHP-FPM Start >/dev/null
echo "[' Date + '%h%d%T '] php-fpm died with no response, all processes restarted" >>log.txt
Else
touch/var/lock/subsys/502
If [' Curl--connect-timeout 5-i http://www.111cn.net/2>/dev/null | grep ' 502 Bad Gateway '-C '!= ' 0 ']
Then
Killall-9 PHP-FPM 2>/dev/null
Killall-9 php-cgi 2>/dev/null
Service PHP-FPM Restart >/dev/null
echo "[' Date + '%h%d%T '] php-fpm died with 502 Bad gateway, all processes restarted" >>log.txt
Fi
Rm-f/var/lock/subsys/502
Fi

The

script needs to have curl installed, the only place that needs to be modified is the URL that is involved in it, that is, through this address to determine whether the server is faulted. The script is executed every 1 minutes by crontab. The service automatically restarts when the fastcgi cannot be answered.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.