Dont Run Cron.d- When Cron.daily-scripts Are Running

Home » CentOS » Dont Run Cron.d- When Cron.daily-scripts Are Running
CentOS 4 Comments

EL6 context:
cronie-1.4.4-16.el6_8.2.x86_64
cronie-anacron-1.4.4-16.el6_8.2.x86_64
crontabs-1.10-33.el6.noarch

I have some cron.d entries that execute scripts in minute intervals and I’m wondering how could an
“official” way look like, to have a condition to not run cron.d entries when cron.daily scripts are running. Sure, I can hack something around file timestamps or so but that feels not so streamlined …

I’d really appreciate any ideas …

4 thoughts on - Dont Run Cron.d- When Cron.daily-scripts Are Running

  • Well, this is anything but elegant, but if your daily occurs at an exact hour and minute you could write two series of per minute cron jobs (a “before’ and an “after”) avoiding that minute.

    Leroy Tennison Network Information/Cyber Security Specialist E: leroy@datavoiceint.com
    2220 Bush Dr McKinney, Texas
    75070
    http://www.datavoiceint.com This message has been sent on behalf of a company that is part of the Harris Operating Group of Constellation Software Inc. These companies are listed here
    . If you prefer not to be contacted by Harris Operating Group please notify us
    . This message is intended exclusively for the individual or entity to which it is addressed. This communication may contain information that is proprietary, privileged or confidential or otherwise legally exempt from disclosure. If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please notify the sender immediately by e-mail and delete all copies of the message.

  • run-parts doesn’t look like it produces a lock, so I’d venture that the simplest way would be:

    */5 * * * *   root pidof -x run-parts || your-command-here

  • I should have noted that this will avoid starting your scripts if run-parts is running, but it won’t prevent run-parts from starting while your script runs.  If that’s important, then you’ll have to modify both your cron jobs and the system crontabs that start run-parts, and use a lock of one sort or another.