Saturday 25 April 2015

If a cron job is failing , it has to send a mail to my email address !.



$ crontab -l
05 20 * * *  /home/oracle/scripts/backup.sh   PROD level0


I have schedule the rman backup in crontab which is mentioned above and it is not triggering the database backup .I want ,If a cronjob is failing,it has to send a mail to my email address.

$ crontab -l
MAILTO=abdul.wasiq01@gmail.com
05 20 * * *  /home/oracle/scripts/backup.sh   PROD level0


When i used above function it has through mail my email address saying
"/bin/sh: /home/oracle/scripts/backup.sh: /bin/ksh: bad interpreter: No such file or directory"


 In the crontab ,it was using Korn shell instead or bash .
Now i have slightly change the crontab

$crontab
MAILTO=abdul.wasiq01@gmail.com
05 20 * * * /bin/bash /home/oracle/scripts/backup.sh PROD level0

Now the backup triggered successfully and got completed .

No comments:

Post a Comment