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.

2 Answers 2

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.

5
  • @MaxMackie: Did you mean crond? Commented Jul 9, 2011 at 20:38
  • I don't think I edited out any letters, I just surrounded it with code tags. My bad if I did. Commented Jul 9, 2011 at 20:54
  • This would be a useful answer if you took a second to explain exactly who the recipient is, and how to access or forward these emails. There's a reason this question is so popular. Commented Jul 9, 2011 at 21:03
  • @MaxMackie: Usually commands are surrounded by code tags, not application names. Commented Jul 9, 2011 at 21:31
  • Sorry, you can remove them if you like. I find it more legible to add code tags around applications like that. Easier to spot them and adds emphasis. Commented Jul 9, 2011 at 22:10
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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.