#/bin/bash # phperrlog v1.0 # by vladimir prelovac http://www.prelovac.com/vladimir/ # # parse error logs on your server and send you daily updates to email # configure options EMAIL=enter email here WORKDIR="/root" TAIL=5 # number of entries to send IGNORE="/backup" # path to ignore # script starts 'ere cd $WORKDIR rm phperrlog.txt LIST=`locate error_log | grep -v $IGNORE`; today=`date +%Y-%m-%d` for i in $LIST do if [ -f $i ]; then time=`date -r $i +%F` if [ "$time" == "$today" ]; then echo $i >>phperrlog.txt echo "---------------------------------" >>phperrlog.txt tail -n $TAIL $i >>phperrlog.txt echo -e "\n\n\n\n" >>phperrlog.txt fi fi done if [ -f phperrlog.txt ]; then mail -s "server error logs - $today" $EMAIL < phperrlog.txt fi