Automatic delivery to email error_log

Wrote a simple shell script, which is like the tail-f command in real time monitors the error log and sends changes to mail. To protect against spam, the script will not send more than one letter per minute. #!/bin/sh tail -f -n0 /var/log/php5-fpm.log | grep PHP | while read LINE; do SEND_BUF="$SEND_BUF\n$LINE" if [ `date +%s` -gt $(($last_time+60)) ]; then last_time=`date +%s` echo "$SEND_BUF" | mail -s "ERROR $LINE" 944406@gmail.com SEND_BUF="" fi done