Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've read a few posts on the web, gone and looked for the file they are mentioning and haven't found it. I'm in Ubuntu 11 and trying to troubleshoot a cron job that isn't running, even though I have it sent to run every 3 minutes. The command in the cron job runs with no errors.

Where does cron store the history of what jobs were run and when? How do I make sure it's enabled?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Cron puts the output of the executed script into an e-mail (use the mail command to read them) or they go to the system logs.

A cron job usually doesn't run because of a huge amount of assumption. Assuming that something runs right when you (YOU as the user) run it, is a good way to make mistakes.

Typical mistakes are missing rights or invalid path. You should test your script if you can start it as the user of the cron job (it is either you, or root), and if you can start it anywhere in the file-system (you should use full paths, not relative ones).

share|improve this answer
    
Hmm, mail doesn't seem to be on ubuntu. I get: ` The program 'mail' can be found in the following packages: * heirloom-mailx * mailutils` neither one is installed though. –  jcollum Dec 13 '11 at 5:26
    
There is no mail under Ubuntu, sorry, I was checking this on Debian. I set up an erroneous cron line, and it is pushing error messages into /var/log/syslog in Ubuntu 11.10. –  karatedog Dec 13 '11 at 9:28
    
Thanks for that. Looks like it doesn't keep those messages long. I was having issues with cron yesterday and the messages are at most 5 hours old. Bummer. –  jcollum Dec 13 '11 at 20:01
    
please post the cron job line, just to check if the timing is correct –  karatedog Dec 14 '11 at 23:05
    
I believe this one wasn't working correctly. The cron job is working correctly now. # Begin Whenever generated tasks for: /mnt/hgfs/projectAlpha/config/schedule.rb 0,15,30,45 * * * * /bin/bash -l -c 'cd /mnt/hgfs/projectAlpha && RAILS_ENV=production bundle exec rake nightly_tasks --silent >> /logs/tasks.log 2>&1' # End Whenever generated tasks for: /mnt/hgfs/projectAlpha/config/schedule.rb (comment is going to mess it up a bit) –  jcollum Dec 15 '11 at 3:09

I'm pretty sure the standard cron doesn't keep a log. Apparently you can cause it to log by adding a cron.debug /var/log/cron entry to /etc/syslog.conf then send syslogd a HUP signal.

Usually, failed jobs result in email to the relevant user.

A common cause of cron job failure is programs that rely on environment variables or paths that are set during interactive login but not by cron.

share|improve this answer
    
Does /etc/syslog.conf exist in Ubuntu? I don't see it there. –  jcollum Dec 13 '11 at 20:03

Your Answer

 
discard

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.