March 22nd, 2012, 10:30 AM
Unscheduled cron job running with no record
I've been digging through the tubes and pipes of the internet to try to find an answer, but haven't had any luck.
My server is Ubuntu 10.04 64bit, fully up to date.
The problem is that a cron job is running when it's not scheduled to. It's supposed to run on the first of the month, but it's been running on the 20th as well.
The line for it in the root (and only) crontab is:
00 07 1 * * php -f /var/w...
All other cronjobs run at their assigned schedules.
I first checked the system/software date and hwclock to see how far out of sync they were. The hwclock was 5 days behind, so I set it using
which corrected the hwclock, but that didn't help. The cron still ran on the wrong day. Interestingly, the date it ran was 5 days later than the (incorrect) date it ran on in the previous month, which was the 15th.
Also, there is no log of it running in /var/log/syslog. All other cronjobs are logged there, though. The job sends me a spreadsheet report, so I always have a record of when it runs. To make sure, I grepped all in /var/log to see if it turned up somewhere else - it didn't.
Thanks everyone. This is driving me nuts!
March 22nd, 2012, 08:22 PM
I'd wrap the command in a script that also logs when the script started and ended (in my own logfile). Maybe that will give an idea of when the job is run.
The man who doesn't read good books has no advantage over the man who can't read them.
March 23rd, 2012, 06:36 AM
If your clock isn't staying in sync, perhaps you should set the system to use ntp. Once you have the right time, you should restart your cron daemon.
There's nothing in cron that tells it to log anywhere (unless yours is configured otherwise). Logging is completely up to the called routines. That said, I'd look at wherever php is configured to log on your system. A lot of times it logs to the default apache logs, even when being run from the cli.
March 23rd, 2012, 08:52 AM
thanks. All cron jobs are logged to syslog. I added some logging to this particular php script as well.
After I set the hwclock a few weeks ago, I restarted the cron daemon and figured that it would use the newly set time.
Guess I'll just have to watch that new log to see what shows up next month.
In the meantime, I'll get the server using ntp. Not sure why it isn't.