Forum Thread: Cron & Anacron, Need Help.

test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

That script is in my crontab, my "system wide" one. Now i understand crontab is "suppose" to execute commands before anacrontab. But i read that command and i can't help to think that the " test -x /usr/sbin/anacron " is saying to see if anacron exists, and to execute if it does, hence the -x option.


is the command just seeing if anacrond exists and is exectuable before running what's after the || opertator? That doesn't seem to make sense.

TL;DR: is that command saying to see if anacrond exists and is executable (and run the directory with scripts in it from anacron), and if not run the command after || instead, which in turn will just run from cron?

Never Miss a Hacking or Security Guide

Get new Null Byte guides every week.

2 Responses

I think what it is saying:

Test to see if anacron is installed. If not, run the scripts located in the /etc/cron.monthly. If anacron is installed, then use it instead.

Apparently a good nights rest help, you are right. Anacron is ran at start up, executing any scripts that havn't been ran by cron and is set up to be. It is ran at other times as well. The system wide crontab runs those scripts either way through anacron in /etc/anacrontab.

Unless anacron isn't installed and if it isn't, when crontab is invoked at the time it's suppose to run it uses run-parts using the path specified in /etc/crontab to run the scripts.

Share Your Thoughts

  • Hot
  • Active