Last active
February 19, 2018 10:22
-
-
Save alexalouit/11040430 to your computer and use it in GitHub Desktop.
HTTP errors regular email report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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