14

I'm using Ubuntu 14.04, and the cron daemon is running:

# ps ax | grep cron
822 ?        Ss     0:00 cron

but it is not executing any jobs. I was previously getting entries in /var/log/syslog such as this:

2014-05-04T11:47:01.839754+01:00 localhost CRON[29253]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ))

but now there are no cron-related entries. I was also getting entries like this in /var/log/auth.log:

2014-05-04T11:47:01.839183+01:00 localhost CRON[29252]: pam_unix(cron:session): session opened for user root by (uid=0)
2014-05-04T11:47:13.495691+01:00 localhost CRON[29252]: pam_unix(cron:session): session closed for user root

but again, now there are no cron-related entries.

I am not aware that anything has changed. I have tried restarting cron:

# service cron restart
cron stop/waiting
cron start/running, process 24907

I tried using crontab -e to add a cron job * * * * * date >> /tmp/somefile which worked, but it installed a new crontab in /var/spool/cron/crontabs/root, whereas I want cron to use the file in /etc/crontab.

Is there any debug option I can use, or a log somewhere that might give an error message that I can investigate?

  • 1
    What displayed to crontab -l? – user345352353 May 8 '14 at 20:05
  • no crontab for root. – jl6 May 8 '14 at 20:12
  • I believe if you do just a little bit of searching on this SE site you'll have an answer. This is a fairly common problem. – mdpc May 9 '14 at 1:11
  • Crons retrieved using the crontab command (-l switch) are user-dependent, while /etc/crontab is used to store system-wide crons. For this reason, tasks saved in /etc/crontab will not appear in anyone's crontab -l. – John WH Smith Aug 18 '14 at 11:15
  • Note that Server Fault has a canonical question about cronjob debugging that may help. – Wildcard Nov 8 '17 at 22:36
4

To further help you debug what is wrong with your cron jobs, you should check your mail. This is usually stored in a file like /var/mail/<user_name> or /var/spool/mail/<user_name>.

These two files are actually hardlinks on my Debian box, but I don't know if this is standard.

Explanation

From the cron(8) page:

When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists).

  • I have checked mail; none is being generated, nor is there a dead.letter file. – jl6 May 9 '14 at 5:59
0

You have shown that there is no crontab for root, do any users have a crontab entry? If you are only using root then you could also check the following directories: /etc/cron.daily/ - /etc/cron.hourly/ - /etc/cron.monthly/ - /etc/cron.weekly

on my machine (centos 6.4) i have mlocate.cron inside of the /etc/cron.daily/ directory and cron runs that script daily.

so I think you just need to add cron jobs.

  • But there is a crontab file in /etc/crontab. Maybe the question is why does crontab -l not acknowledge it? – jl6 May 9 '14 at 5:59
0

I resolved this by changing the permissions on /etc/crontab to the following:

-rw-r--r-- 1 root root 778 May 10 21:31 /etc/crontab

Previously it was -rw-rw-r--. That was the only change. It wasn't working, now it is. Still not sure why.

  • 1
    The root crontab would execute any commands as root. Permissions allowing write access to non-root would be considered a security hole. – ChuckCottrill May 16 '14 at 23:10
  • @ChuckCottrill: But the group write bit would only have given write access to those in the root group - which is presumably just root user(s)? – jl6 May 17 '14 at 19:24
0

I also had a similar type of problem, but after specifying the root as user on the /etc/crontab, the cron job started triggering.

It might be due to the syntax followed on the crontab -e which is different from the /etc/crontab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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