View Full Version : A question on Cron...

5th June 2008, 12:18 AM
I am running Fedora Core 5 Linux and up till today I've been running all batch jobs by simply putting batch scripts in the /etc/cron.xxx folders (ie. cron.daily, cron.hourly, etc.). I have a job that I need to run IN ADDITION to these jobs, but it needs to run every 15 minutes. So I did some searching on the 'net and found out how to use the crontab -e command to create the job. I did this, and its running just fine.

But what I don't understand is if what I did would stop all of these other jobs from running (ie. the scripts in /etc/cron.xxxx folders). I have no idea how these are implemented and if both work fine together in harmony, or if you use crontab you turn off all the other cron abilities.

So did I do this correct? Or am I doomed that my scripts in the /etc/cron.xxxx folders will never run automagically again?

BTW, I always use su to do this, so the crontab -e command was run as root and shows up in /var/spool/cron as a root file.

Thanks in advance for anyone clearing this up.


5th June 2008, 12:56 AM
You did everything exactly right. Adding a 'cron' entry via 'crontab -e' should not disturb the hourly, daily, weekly, etc. cron jobs that are setup.

5th June 2008, 01:23 AM
I was 99% sure of my answer when I posted, but I wanted to make sure I wasn't giving out bad information, so I just tested on my system. I added a cron job using 'crontab -e' as root. Everything worked as expected. I made sure that both the hourly job that I had setup and the new job both ran. So you should be all set.

Just wanted to add that you can also add jobs to the /etc/cron.d directory for anything that does not fall into the hourly, daily, weekly, monthly categories.

5th June 2008, 02:02 AM
Thanks so much for the clarification. Here I am fretting that my nightly jobs won't run and it will be chaos in the morning for me. Unfortunately they are all database oriented, and reset key statistical data, so I can't test them other than running them in production.

Anyway I'll get a good night's sleep now. Thanks again.


5th June 2008, 02:48 PM
Bingo! It worked fine. Thanks for all the help on this. Yes, my new crontab job is working WITH the cron.daily jobs without any issue.

Now the one question I have left is about the timing on the cron.daily jobs. Is there a place that one can set the time of day that these jobs get fired off at? I checked my date value and the system clock appears to be set correctly. I would have expected these jobs to fire off at 12 midnight, but they are starting at 5AM instead. Can that be changed?


5th June 2008, 03:22 PM
Glad I could help. Regarding your question about the cron.daily jobs, have a look at the crontab file in /etc. The second field is used for the hour of the day when the cron jobs are run. For my daily, weekly, and monthly jobs it is set to 4 (for 4 AM). If you want the daily jobs to fire off at 12 midnight, or thereabouts, just change the second field to a '0' (zero).

I'm pretty sure the cron daemon will pick up any changes you make automatically, but to be safe it might not be a bad idea to stop and start the cron service (/usr/sbin/service crond stop; /usr/sbin/service crond start).

5th June 2008, 04:05 PM
Thank you so much again. I was able to verify that /etc/crontab did contain a 4 as the 2nd value, and I've changed that to a 0 so that it fires off at midnight. I've restarted the service, so I'll check tomorrow and see how it goes.

Again, much appreciated