Justine
Justine

Reputation: 115

How to correctly setup cron job notifications

I'm trying to setup to receive notification everytime my cron job fails, but i'm not sure if I am doing it correctly. This is my current setup.

The second line, i'm trying to clean my csv file, while the third line, i want that clean file to be copied to google cloud storage. How do I receive a notification when any of the jobs fail?

MAILTO:[email protected]
*/1 * * * *  csvcut -x -e UTF-16 myfile.csv > newfile.csv
*/6 * * * *  gsutil mv -r newfile.csv gs://gcsbucket

Upvotes: 0

Views: 1214

Answers (1)

marian.vladoi
marian.vladoi

Reputation: 8056

One thing that I noticed is MAILTO:[email protected]

To set the MAILTO variable you should use:

      [email protected] 

Sending Email Alerts Through Cron

Also your system should be able to send mails. Please check this related question on SO which describes how to configure your system.

How do I set Cron to send emails

To get an email every time a cron job fails you should redirect all of your standard output to /dev/null or to some file and the STDERR messages will be emailed.

Get email when a cron job fails

Upvotes: 1

Related Questions