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