One of the prerequisites of a successful site is making sure everything is running as it should. When you have a lot of sites to take care of, tracking the problems can be really time consuming.
Especially I was lacking reporting on PHP errors produced by various sites. So I wrote this bash script which purpose is to once a day send you an email with all errors happening on all your sites on the server.
#/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
Set the email and other configration options first.
Then, add the script to your cron using, crontab -e. This will start the script every day at 11:55pm
55 23 * * * /root/phperrlog >/dev/null 2>&1
- Better handling of 404 pages using Google
- Do it Yourself: Optimize your WordPress Site Titles
- Check your website for virus attack !
Posted in: SEO, WordPress
TAGS:apache error logs, consolidate logs apache, consolidate output cron scripts, error logs php, mail apache error, monitor apache error log, monitor apache server php, monitor php logs, php apache monitoring, php error, php error log, php error monitoring, php logs, php server monitor, seo apache logs, unix projects