0

This is a ridiculous newbie question, sorry!

I am running a (Python) script regularly using cron.

I would like to log the output to a logfile, and I would like to be emailed with any errors that occur if the script does not complete.

Currently my thoughts are: write a shell script which runs the script, and outputs the result to a log, and emails me if there are errors. Then run that shell script from cron.

But is there anything inbuilt in cron that would do some of this for me?

Would be handy if so.

Thanks.

Richard
  • 1,015

2 Answers2

2

cron already emails the output of the job to the owner of the cron job if not directed otherwise. Use tee if you also want to redirect it to a file.

nopcorn
  • 16,982
0

Be careful that your job doesn't generate any output if you use that method, otherwise you'll find yourself ignoring the emails by the time something does go wrong. The unix tool philosophy of "no news is good news" developed for a reason.

Stephanie
  • 2,408