If I have multiple files in cron.weekly and one script takes hours to finish. Will it block other scripts in cron.weekly?
On 9/16/2014 13:24, Matt wrote:
If I have multiple files in cron.weekly and one script takes hours to finish. Will it block other scripts in cron.weekly?
I doubt it, based on the results of this crontab on EL7:
51 13 * * * echo start 1 ; sleep 2m ; echo end 1 51 13 * * * echo start 2 ; sleep 2m ; echo end 2
At 13:51, nothing appeared in my mail file. Two minutes later, two different messages appeared, each with the expected "echo" outputs. Thus, they must have run in parallel.
On 2014-09-16, Warren Young warren@etr-usa.com wrote:
On 9/16/2014 13:24, Matt wrote:
If I have multiple files in cron.weekly and one script takes hours to finish. Will it block other scripts in cron.weekly?
I doubt it, based on the results of this crontab on EL7:
51 13 * * * echo start 1 ; sleep 2m ; echo end 1 51 13 * * * echo start 2 ; sleep 2m ; echo end 2
At 13:51, nothing appeared in my mail file. Two minutes later, two different messages appeared, each with the expected "echo" outputs. Thus, they must have run in parallel.
Those are two distinct cron jobs. The scripts in /etc/cron.weekly are all run by the same cron job in /etc/crontab.
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
I believe that run-parts runs each script in serial, and therefore a long-running weekly script will block.
If you don't care when you get the output, and have only one long-running script, you can rename it so that it runs last. Otherwise, you'd need to put the long-running job into its own cron entry.
--keith
Matt,
Keith answer applies to centos 5 and 6, mine to centos 7. In any case, scripts will exec one at a time in alphabetical order.
On Tue, Sep 16, 2014 at 7:27 PM, Keith Keller kkeller@wombat.san-francisco.ca.us wrote:
On 2014-09-16, Warren Young warren@etr-usa.com wrote:
On 9/16/2014 13:24, Matt wrote:
If I have multiple files in cron.weekly and one script takes hours to finish. Will it block other scripts in cron.weekly?
I doubt it, based on the results of this crontab on EL7:
51 13 * * * echo start 1 ; sleep 2m ; echo end 1 51 13 * * * echo start 2 ; sleep 2m ; echo end 2
At 13:51, nothing appeared in my mail file. Two minutes later, two different messages appeared, each with the expected "echo" outputs. Thus, they must have run in parallel.
Those are two distinct cron jobs. The scripts in /etc/cron.weekly are all run by the same cron job in /etc/crontab.
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
I believe that run-parts runs each script in serial, and therefore a long-running weekly script will block.
If you don't care when you get the output, and have only one long-running script, you can rename it so that it runs last. Otherwise, you'd need to put the long-running job into its own cron entry.
--keith
-- kkeller@wombat.san-francisco.ca.us
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Tue, Sep 16, 2014 at 4:24 PM, Matt matt.mailinglists@gmail.com wrote:
If I have multiple files in cron.weekly and one script takes hours to finish. Will it block other scripts in cron.weekly?
Yes. They're run from "anacron -s" by default. If you need a job to run in parallel, configure it into /etc/cron.d at an adecuate time on sundays (as you surely know, you can't use the script directly in cron.d).