Shell-PHP Tutorial for monitoring php process and exception log Check

Source: Internet
Author: User
Tags server error log
Monitor the PHP process and error log check shell1: when asynchronous processing is performed, the program will inevitably fail. this shell can be used to listen to the PHP script process processed by the queue, if the process is dead, it will restart. #! Binbashprocess 'PS-ef | grepwwwprojecthandle. php | grep-vgrep | wc-L' if [$ process-e monitor the shell for PHP process and error log Check
1: some asynchronous processing may inevitably result in program failure. this shell can be used to listen to the PHP script process processed by the queue. if the process dies, it will be restarted.
#! /Bin/bashprocess = '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 log here to learn about the 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.
#! /Bin/shnow = 'date + % Y % m % d % H' # The current time ends in the hour logPath =/data/log/# log directory thisIp = 'ifconfig- | 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" ]; thenecho $ thisIp "server have error log;-logpath: "$ logPath $ fileName | mail-s server error log [email protected] # send mail to relevant personnel # if there is an implemented notification mechanism, 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.