Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Created April 17, 2018 06:38
Show Gist options
  • Save alexalouit/20db93a3ffa6ef0f2136a54c3df745fc to your computer and use it in GitHub Desktop.
Save alexalouit/20db93a3ffa6ef0f2136a54c3df745fc to your computer and use it in GitHub Desktop.
ISPConfig crons regular email report
#!/bin/bash
#
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/cron-errors.sh >> /root/scripts/cron.log
email=""
dir="/tmp/"
file="/var/www/clients/client*/web*/private/cron*.log"
cd $dir
if [ -f ./cron-errors ]
then
if [ -f ./cron-errors-last ]
then
rm ./cron-errors-last
fi
mv ./cron-errors ./cron-errors-last
touch ./cron-errors
chmod -R 777 ./cron-errors
else
touch ./cron-errors
chmod -R 777 ./cron-errors
fi
cat $file > ./cron-errors
if [ -f ./cron-errors-last ]
then
if diff ./cron-errors ./cron-errors-last >/dev/null ;
then
rm ./cron-errors
else
contain=$(diff ./cron-errors ./cron-errors-last)
echo -e "Cron Errors report:\n $contain" | mail -s "Cron Errors report" $email
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment