Shell that monitors PHP processes and Exception Log checks

Source: Internet
Author: User
Shell that monitors PHP processes and error log checks
1: When doing some asynchronous processing, it is inevitable that the program hangs, this shell can be used to listen to the queue processing of the PHP script process, if the process is dead 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# here can also record the log, understand the situation of the dead fi


2: interface interaction between layers or systems in real development is unavoidable, but it is essential for some core interactive logging. In the event of an exception in the interaction process, it is necessary to quickly notify the relevant developer.
#!/bin/shnow= ' Date +%y%m%d%h ' #当前时间截止到小时logPath =/data/log/#日志的目录thisIp = ' Ifconfig-a|grep inet|grep-v 127.0.0.1|grep -V Inet6|head-n1|awk ' {print $} ' |tr-d ' addr: ' #如果程序发布到多台机器取出当前机器的IP #errorlogfile= ' find $logPath-name $errorBegin ' *. Log "' #如果是查找所有的错误日志可用这个fileName = $now" _test_error.log "#程序中抛异常时记录的日志if [-F" $logPath $filename "];thenecho $thisIp" Server has error log; -logpath: "$logPath $filename|mail-s Server error log user@domain.com #给相关人员发mail # If there is an already implemented notification mechanism, the program can be implemented here 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.