JarDo Posted August 5, 2012 Share Posted August 5, 2012 I schedule cron jobs by placing scripts in /etc/cron.daily an /etc/cron.hourly. This has worked for years with no issue. I noticed yesterday that recently my cron jobs have stopped running. I hope someone can help me. The scripts are in the correct location (i.e. /etc/cron.daily) I found the crontab file on my server is located in /tmp and when I cat it it looks Okay. I did notice that if I try to 'crontab -l' I get an error "no crontab for root". This looks like it might be a problem. but, I don't know. Also, I tested by firing the scripts manually. They still do their job with no error. It is just that they are no longer running as scheduled via cron. Please, I could use some advice from anyone with cron knowledge. Link to comment
PeterB Posted August 5, 2012 Share Posted August 5, 2012 The file you're looking for (where it is in my system) is /var/spool/cron/crontabs/root Link to comment
Joe L. Posted August 5, 2012 Share Posted August 5, 2012 The file you're looking for (where it is in my system) is /var/spool/cron/crontabs/root if you can read the crontab file in /tmp, try cat /tmp/crontab | crontab then try crontab -l You probably typed crontab and then quit without supplying one, basically emptying it. Joe L. Link to comment
JarDo Posted August 5, 2012 Author Share Posted August 5, 2012 Please excuse my ignorance. For some reason cron configuration has me scratching my head. It worked before and now it doesn't. Peter - I checked... I have a /var/spool/cron/crontabs, but it doesn't contain a 'root' subdirectory. Should it? Joe - I tried as you said. I assume that "cat /tmp/crontab | crontab" should pipe the crontab contents from the /tmp/ location to the root's crontab file (wherever that might be located). But, when I subsequently issued a "crontab -l" the response is still "no crontab for root" Link to comment
PeterB Posted August 5, 2012 Share Posted August 5, 2012 Peter - I checked... I have a /var/spool/cron/crontabs, but it doesn't contain a 'root' subdirectory. Should it? 'root' should be a file containing all the crontab lines for the root user. Link to comment
JarDo Posted August 6, 2012 Author Share Posted August 6, 2012 Peter - I checked... I have a /var/spool/cron/crontabs, but it doesn't contain a 'root' subdirectory. Should it? 'root' should be a file containing all the crontab lines for the root user. No files exist at that location. Should I copy the crontab file that is in my /tmp directory to this location and name it 'root'? Link to comment
Joe L. Posted August 6, 2012 Share Posted August 6, 2012 Peter - I checked... I have a /var/spool/cron/crontabs, but it doesn't contain a 'root' subdirectory. Should it? 'root' should be a file containing all the crontab lines for the root user. No files exist at that location. Should I copy the crontab file that is in my /tmp directory to this location and name it 'root'? just reboot. That will re-create the default crontab file. (unless you want to give it a try otherwise without rebooting. The actual crontab is in memory and only read when needed. In that case, perhaps since the file is missing it is unable to accept the new crontab commands. Joe L. Link to comment
PeterB Posted August 6, 2012 Share Posted August 6, 2012 As Joe says, that file should be created/placed in the correct position at boot time. If it is missing, something has removed it - a user action, or an add-on of some sort. Some simple testing, starting with a standard, 'vanila' install should allow you to identify the culprit. Link to comment
JarDo Posted August 10, 2012 Author Share Posted August 10, 2012 Thank you Peter & Joe. I was able to find the cause and have fixed my issue. But, the most important thing is that I learned a little bit more about how cron works. The big clue for me was that there WAS supposed to be a file called 'root' at /var/spool/cron/crontabs. Next time I have cron issues I'll have a much easier time finding the solution myself. Cheers! Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.