This page http://wiki.ci.uchicago.edu/I2U2/WebalizerConfiguration suggests renaming /etc/cron.daily/logrotate so it comes after /etc/cron.daily/webalizer - webalizer should be done before logrotate kicks in.

Is that true ? Will cron.daily wait for jobs to finish before starting the next one ?


The scripts in cron.daily and the others are executed using run-parts if anacron is not installed. You can see this in /etc/crontab:

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

run-parts will execute each executable in the directory, and wait for each to complete before running the next. Here is a test using these two scripts:

$ cat cron/1test
echo script1
sleep 10

$ cat cron/2test
echo script2
sleep 10


$ run-parts --verbose cron
run-parts: executing cron/1test
Monday 6 January  10:38:42 EST 2014
Monday 6 January  10:38:52 EST 2014
run-parts: executing cron/2test
Monday 6 January  10:38:52 EST 2014
Monday 6 January  10:39:02 EST 2014

This differs from scheduling each job in cron, which will run them parallel if they overlap.

| improve this answer | |
  • Good job on finding this. After I posted my answer I got an idea cron executes them in different way (/etc/crontab and cron.daily stuff). Well done. – VL-80 Jan 6 '14 at 0:01

I just created test cron job which executes every minute:


echo "123" >> /home/user/test-file

sleep 100

echo "234" >> /home/user/test-file

So I did see overlap in htop. I mean there was periods of time when I saw two processes running simultaneously. 123 was echoed at the begging of the minute and 234 was echoed at 40 seconds of next minute (because of sleep 100). In period of 40 seconds to beginning of next minute there was just one process.

That means cron fires jobs and does not wait for them to finish.

I'll try to represent it graphically:

0 minute 00 seconds 123 <----first execution
1 minute 00 seconds 123 <----second execution
1 minute 40 seconds 234 <----first execution
2 minute 00 seconds 123 <----third execution
2 minute 40 seconds 234 <----second execution
3 minute 00 seconds 123 <----fourth execution
3 minute 40 seconds 234 <----third execution

At least this is true for jobs in the /etc/crontab with vixie-cron on fresh updated Gentoo.

As Paul discovered - stuff in cron.daily executes in the different way.

| improve this answer | |

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.