[QUOTE=gniecka;19809]I have fixed my cron configuration - now it works
30 23 * * * /sap_instalki/backup.sh -q -p --retention=7 | mail -s "backup" firstname.lastname@example.org
My concern is - email is sent when backup script is started, but I have no info if this script was success or not.
Kindly advise how to modify contab email notification smth like that:
if backup scrip = success
mail root@host -S"backup success"
mail root@host -S"backup failure"
Doesn’t the output of the script tell you success of failure? With what you have set up you are only going to get the output of stdout emailed to you, so you may not see errors.
Cron will email you both the stderr and stdout from cronjobs. Instead of piping the output of the stdout in to the mail command, you need to get cron to send it’s emails to the desire email address. Who’s crontab is the connjob set in?
If the cronjob is set in /etc/crontab or root’s crontab the output will be emailed to root. You can have a copy of an email sent to root copied to another email address by adding the address to the relevant line in /etc/aliases. If you have a look at that file it explains what to do.
If you really want to do the set up you describe where you get different subject headed emails sent to you depending on success of failure that could be done, but it’s a clunky way of doing it.