7.5. Run recurring actions with cron#

Use the cron service to start recurring actions such as processing log files at a defined time. This page refers to such an action as a cron job and describes three ways to define cron jobs:

  • Predefined cron directories

  • Local cron jobs in /etc/cron.d/

  • Cron jobs through Univention Configuration Registry

7.5.1. Predefined cron directories#

Each Nubus for UCS system includes these directories:

  • /etc/cron.hourly/

  • /etc/cron.daily/

  • /etc/cron.weekly/

  • /etc/cron.monthly/

Executable shell scripts in these directories run hourly, daily, weekly, or monthly.

7.5.2. Define local cron jobs in /etc/cron.d/#

Use one line with seven columns to define a cron job:

  • Minute (0-59)

  • Hour (0-23)

  • Day (1-31)

  • Month (1-12)

  • Weekday (0-7); 0 and 7 both mean Sunday

  • Name of the user who runs the job, for example root

  • Command to run

Specify the time in different ways. Enter a particular minute, hour, or other value, or use * to run an action every minute, hour, or other interval. You can also define intervals. For example, */2 in the minute field runs an action every two minutes.

Example:

30 * * * * root /usr/sbin/jitter 600 /usr/share/univention-samba/slave-sync

7.5.3. Define cron jobs in Univention Configuration Registry#

You can also define cron jobs in Univention Configuration Registry. Use this approach when you set cron jobs through a UDM policy and apply them to multiple computers.

Each cron job uses at least two UCR variables. Replace JOBNAME with a unique identifier for the cron job. This placeholder appears in the variable names in the following lists.

Required variables:

Optional variables and defaults:

  • By default, cron runs the job as root. Use cron/JOBNAME/user to specify a different user.

  • Use cron/JOBNAME/mailto to send command output by email.

  • Use cron/JOBNAME/description to add a description.