Cron is the Linux task scheduler that is responsible for making sure scripts run at their specified times. Cron is often used for backup scripts and running custom scripts. In the event a task runs into problems or errors Cron generally tries to email the local administrator of the machine. this means it tries to send an email to itself.
We can change this default behavior by changing the MAILTO variable (It won't work if you have not setup an email server or SMTP)
Setting MAILTO variable
Edit the crontab by entering crontab -e and add
MAILTO=your.email@your_provider.com
It should look something as below
Specify email for each script
If we don’t want all output to go to the same email address we can specify the output of a particular script to go to a different email address
0 8 * * * /mnt/dbbkup/Databkup/FULL_SCHEMA_BACKUPS/ETL/SQLs/load.sh | mail -s "QA Load 8AM" someaddress@email.com
If you don't want email alerts add ">/dev/null 2>&1" at the end of the command
0 8 * * * /mnt/dbbkup/Databkup/FULL_SCHEMA_BACKUPS/ETL/SQLs/load.sh >/dev/null 2>&1
We can change this default behavior by changing the MAILTO variable (It won't work if you have not setup an email server or SMTP)
Setting MAILTO variable
Edit the crontab by entering crontab -e and add
MAILTO=your.email@your_provider.com
It should look something as below
Specify email for each script
If we don’t want all output to go to the same email address we can specify the output of a particular script to go to a different email address
0 8 * * * /mnt/dbbkup/Databkup/FULL_SCHEMA_BACKUPS/ETL/SQLs/load.sh | mail -s "QA Load 8AM" someaddress@email.com
If you don't want email alerts add ">/dev/null 2>&1" at the end of the command
0 8 * * * /mnt/dbbkup/Databkup/FULL_SCHEMA_BACKUPS/ETL/SQLs/load.sh >/dev/null 2>&1
No comments:
Post a Comment