salt.states.cron

Management of cron, the Unix command scheduler.

The cron state module allows for user crontabs to be cleanly managed.

Cron declarations require a number of parameters. The timing parameters need to be declared: minute, hour, daymonth, month, and dayweek. The user whose crontab is to be edited also needs to be defined.

By default, the timing arguments are all * and the user is root. When making changes to an existing cron job, the name declaration is the unique factor, so if an existing cron that looks like this:

date > /tmp/crontest:
  cron.present:
    - user: root
    - minute: 5

Is changed to this:

date > /tmp/crontest:
  cron.present:
    - user: root
    - minute: 7
    - hour: 2

Then the existing cron will be updated, but if the cron command is changed, then a new cron job will be added to the user's crontab.

salt.states.cron.absent(name, user='root', minute='*', hour='*', daymonth='*', month='*', dayweek='*')

Verifies that the specified cron job is absent for the specified user; only the name is matched when removing a cron job.

name
The command that should be absent in the user crontab.
user
The name of the user who's crontab needs to be modified, defaults to the root user
minute
The information to be set into the minute section, this can be any string supported by your cron system's the minute field. Default is *
hour
The information to be set in the hour section. Default is *
daymonth
The information to be set in the day of month section. Default is *
month
The information to be set in the month section. Default is *
dayweek
The information to be set in the day of week section. Default is *
salt.states.cron.file(name, source_hash='', user='root', template=None, context=None, replace=True, defaults=None, env=None, backup='', **kwargs)

Provides file.managed-like functionality (templating, etc.) for a pre-made crontab file, to be assigned to a given user.

name

The source file to be used as the crontab. This source file can be hosted on either the salt master server, or on an HTTP or FTP server. For files hosted on the salt file server, if the file is located on the master in the directory named spam, and is called eggs, the source string is salt://spam/eggs.

If the file is hosted on a HTTP or FTP server then the source_hash argument is also required

source_hash
This can be either a file which contains a source hash string for the source, or a source hash string. The source hash string is the hash algorithm followed by the hash of the file: md5=e138491e9d5b97023cea823fe17bac22
user
The user to whom the crontab should be assigned. This defaults to root.
template
If this setting is applied then the named templating engine will be used to render the downloaded file. Currently, jinja and mako are supported.
context
Overrides default context variables passed to the template.
replace
If the crontab should be replaced, if False then this command will be ignored if a crontab exists for the specified user. Default is True.
defaults
Default context passed to the template.
backup
Overrides the default backup mode for the user's crontab.
salt.states.cron.present(name, user='root', minute='*', hour='*', daymonth='*', month='*', dayweek='*')

Verifies that the specified cron job is present for the specified user. For more advanced information about what exactly can be set in the cron timing parameters, check your cron system's documentation. Most Unix-like systems' cron documentation can be found via the crontab man page: man 5 crontab.

name
The command that should be executed by the cron job.
user
The name of the user who's crontab needs to be modified, defaults to the root user
minute
The information to be set into the minute section, this can be any string supported by your cron system's the minute field. Default is *
hour
The information to be set in the hour section. Default is *
daymonth
The information to be set in the day of month section. Default is *
month
The information to be set in the month section. Default is *
dayweek
The information to be set in the day of week section. Default is *

Table Of Contents

Previous topic

salt.states.cmd

Next topic

salt.states.debconfmod