Order of Execution of Scripts on *nix Distributions using Cron Folders

Distributions such as Debian or Ubuntu conveniently create folders such as /etc/cron.daily, /etc/cron.hourly, etc, where scripts can be placed such that they are executed on a schedule. Running crontab -e in order to view the crontab, reveals that cron is using a script called run-parts in order to execute all scripts within such folders and "run-parts" specifies that scripts are run in lexicographical order according to "the C/POSIX locale character collation rules".

This allows users to organize folders such as /etc/cron.daily with scripts, say, preceded by numbers in order to establish some precedence. For example, here is a folder structure of /etc/cron.daily:

---+ etc
      +
      |
      +---+ cron.daily
                +
                |
                +--------+ 00-first
                |
                +--------+ 50-mid
                |
                +--------+ 99-last
                |
                +--------+ order-unimportant
                |
                +--------+ some-other-script

In this example, order-unimportant and some-other-script are scripts where the order of execution relative to each other is irrelevant (order-unimportant will always precede some-other-script due to lexicographical order). The scripts 00-first, 50-mid and 99-last will now run in the order that they are mentioned due to being prefixed with numbers in increasing order.


fuss/cron.txt ยท Last modified: 2024/07/07 04:24 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.