Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Last active February 19, 2018 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexalouit/11040430 to your computer and use it in GitHub Desktop.
Save alexalouit/11040430 to your computer and use it in GitHub Desktop.
HTTP errors regular email report
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/httpd-errors.sh >> /root/scripts/cron.log
email=""
dir="/tmp/"
file="/var/log/httpd/*/error.log"
cd $dir
if [ -f ./script-httpd-errors ]
then
if [ -f ./script-httpd-errors-last ]
then
rm ./script-httpd-errors-last
fi
mv ./script-httpd-errors ./script-httpd-errors-last
touch ./script-httpd-errors
chmod -R 777 ./script-httpd-errors
else
touch ./script-httpd-errors
chmod -R 777 ./script-httpd-errors
fi
cat $file > ./script-httpd-errors
if [ -f ./script-httpd-errors-last ]
then
if diff ./script-httpd-errors ./script-httpd-errors-last >/dev/null ;
then
rm ./script-httpd-errors
else
contain=$(diff ./script-httpd-errors ./script-httpd-errors-last)
echo -e "HTTPD report (errors.log):\n $contain" | mail -s "HTTPD report (errors.log)" $email
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment