Shell that monitors PHP processes and Error Log checks

Source: Internet
Author: User


Shell 1 that monitors PHP processes and Error Log checks: When asynchronous processing is performed, it is inevitable that the program will be suspended. This shell can be used to listen to PHP script processes processed by the queue, if the process is dead, it will restart. Www.2cto.com Python code #! /Bin/bash process = 'ps-ef | grep'/www/project/handle. php' | grep-v grep | wc-l 'if [$ process-eq 0]; then/usr/bin/php/www/project/handle. php # You can also record the logs here to learn about failures. fi 2: in actual development, interface interaction between layers or systems is inevitable, however, some core interaction logs are essential. Once an exception occurs during the interaction process, developers must be notified quickly. Python code #! /Bin/sh now = 'date + % Y % m % d % H' # logPath =/data/log/# log directory thisIp = 'ifconfig- a | grep inet | grep-v 127.0.0.1 | grep-v inet6 | head-n1 | awk '{print $2}' | tr-d "addr: "'# If the program is published to multiple machines, retrieve the IP address of the current machine # errorLogFile = 'Find $ logPath-name $ errorBegin "*. log "'# if you are looking for all error logs, use this fileName = $ now" _ test_error.log "# if [-f" $ logPath $ fileName" ]; then echo $ thisIp "server have error log;-logpath: "$ logPath $ fileName | mail-s server error log user@domain.com # send mail to related personnel # if there is a notification mechanism already implemented, execute this program here to fi
 

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.