Ubuntu – crontab Suddenly Stopped Working

11.10cron

Ok so here is my problem, I recently updated my server and change some jsp files which are used to do automatic announcements. The crontab has all the .sh files listed within it and the .sh files run the jsp files to display the announcements.

After I finished updating the jsp files, I rebooted the server and ever since then the announcements have stopped running. I can run the .sh files via putty manually and they work perfectly fine so the changes I made to the jsp files are not the problem.

I did some research before posting here and I checked the syslog for cron entries. Up until the point I rebooted my server the cron service was running as it should. Since the reboot there has been no entries in the syslog for cron.

I've tried rebooting the server again, I also tried restarting the cron service, I also even tried stopping the service completely and starting it again with no effect. I can't figure out why the cron service would suddenly stop working as nothing to do with cron or any of the operating files were touched during the update of my server.

Does anyone have any suggestions as to why it may have stopped working?
I'm using Ubuntu Server 11.10

Best Answer

1. Note down all the cron jobs for all users including root, for example:

To list the root's crontab

sudo crontab -l

To list your crontab

crontab -l

2. Delete the crontab complete for all users using the following

To delete the root's crontab

sudo crontab -r

To delete your crontab

crontab -r

3. Restart the system

4. Place your jobs back into the cron (Preferably the root's cron) either by creating a text file then pointing cron to that file or manually.

To set up manually

sudo crontab -e

To point cron to a text file

sudo crontab <filename>

Logically, preferably entered in the order of occurance. For example if you have a job that runs before another (in time) place that above.

Remember that the cron file or crontab must have entries in the following format

m h dom mon dow full path command

For example shutdown at 2:30PM ever day of week except weekends would be

30 14 * * 2,3,4,5,6 /sbin/shutdown

Another example run a script file (test.sh - located in /usr/local/myScripts folder) every monday at 2:00AM would be

0 2 * * 2 /usr/local/myScripts/test.sh

I had the same problem with cron, once and I remember reading in a forum that we need to delete the user's cron and restart the system then recreate it.

Related Question