Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
@MaxMackie: Did you mean crond? – Ignacio Vazquez-Abrams Jul 9 '11 at 20:38
I don't think I edited out any letters, I just surrounded it with code tags. My bad if I did. – n0pe Jul 9 '11 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. – Daniel Beck Jul 9 '11 at 21:03
@MaxMackie: Usually commands are surrounded by code tags, not application names. – Ignacio Vazquez-Abrams Jul 9 '11 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. – n0pe Jul 9 '11 at 22:10

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.