I have scheduled a script
take_backup.sh in crontab like so
00 19 * * * bash /home/test/take_backup.sh > /home/test/backup.log 2>&1 || mail -s "Backup failed, check attached logs" email@example.com < /home/test/backup.log
The requirement is to only send an email notification with the logs attached when the cron fails with a non zero exit code. I have set up logs and exit codes in the script to provide more details in
backup.log. However, when this cron fails, I do not receive any notification.
Where am I going wrong?