(debian-policy.info)Cron jobs


Next: Menus Prev: Console messages from init d scripts Up: The Operating System
Enter node , (file) or (file)node

9.5 Cron jobs
=============

Packages must not modify the configuration file ‘/etc/crontab’, and they
must not modify the files in ‘/var/spool/cron/crontabs’.

If a package wants to install a job that has to be executed via cron, it
should place a file named as specified in *note Cron job file names:
146. into one or more of the following directories:

   - ‘/etc/cron.hourly’

   - ‘/etc/cron.daily’

   - ‘/etc/cron.weekly’

   - ‘/etc/cron.monthly’

As these directory names imply, the files within them are executed on an
hourly, daily, weekly, or monthly basis, respectively.  The exact times
are listed in ‘/etc/crontab’.

All files installed in any of these directories must be scripts (e.g.,
shell scripts or Perl scripts) so that they can easily be modified by
the local system administrator.  In addition, they must be treated as
configuration files.

If a certain job has to be executed at some other frequency or at a
specific time, the package should install a file in ‘/etc/cron.d’ with a
name as specified in Note: Cron job file names.  This file uses the
same syntax as ‘/etc/crontab’ and is processed by ‘cron’ automatically.
The file must also be treated as a configuration file.  (Note that
entries in the ‘/etc/cron.d’ directory are not handled by ‘anacron’.
Thus, you should only use this directory for jobs which may be skipped
if the system is not running.)

Unlike ‘crontab’ files described in the IEEE Std 1003.1-2008 (POSIX.1)
available from The Open Group(1), the files in ‘/etc/cron.d’ and the
file ‘/etc/crontab’ have seven fields; namely:

  1. Minute [0,59]

  2. Hour [0,23]

  3. Day of the month [1,31]

  4. Month of the year [1,12]

  5. Day of the week ([0,6] with 0=Sunday)

  6. Username

  7. Command to be run

Ranges of numbers are allowed.  Ranges are two numbers separated with a
hyphen.  The specified range is inclusive.  Lists are allowed.  A list
is a set of numbers (or ranges) separated by commas.  Step values can be
used in conjunction with ranges.

The scripts or ‘crontab’ entries in these directories should check if
all necessary programs are installed before they try to execute them.
Otherwise, problems will arise when a package was removed but not purged
since configuration files are kept on the system in this situation.

Any ‘cron’ daemon must provide ‘/usr/bin/crontab’ and support normal
‘crontab’ entries as specified in POSIX. The daemon must also support
names for days and months, ranges, and step values.  It has to support
‘/etc/crontab’, and correctly execute the scripts in ‘/etc/cron.d’.  The
daemon must also correctly execute scripts in
‘/etc/cron.{hourly,daily,weekly,monthly}’.

Cron job file names
   ---------- Footnotes ----------

   (1) https://www.opengroup.org/onlinepubs/9699919799/


automatically generated by info2www version 1.2.2.9