#!/bin/bash # Mail out PHP errors that are in the apache error log. errorLog=/var/log/php/fpm-error.log email=postmaster@example.com # Send report here #FPM Logging errors=$(/usr/sbin/logtail2 $errorLog | grep "PHP " | awk -F'] PHP ' '{print $2}') errors=$(echo "$errors" | sort | uniq | rev | sort -k4 | rev) # Check that we actually have some errors if [ -n "$errors" ] then echo "$errors" | mail "$email" -s "Apps PHP Log entries `date +'%Y-%m-%d %H:%M'`" fi