Work with cron
Note
Salt does not escape cron metacharacters automatically. You should backslash-escape percent characters and any other metacharacters that might be interpreted incorrectly by the shell.
Return the specified entry from user's crontab. identifier will be used if specified, otherwise will lookup cmd Either identifier or cmd should be specified.
User's crontab to query
Search for line with identifier
Search for cron line with cmd
CLI Example:
salt '*' cron.get_entry root identifier=task1
Return the contents of the specified user's crontab
CLI Example:
salt '*' cron.list_tab root
This function is an alias of list_tab
.
Return the contents of the specified user's crontab
CLI Example:
salt '*' cron.list_tab root
Return the contents of the user's crontab
CLI Example:
salt '*' cron.raw_cron root
This function is an alias of rm_job
.
Remove a cron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match.
CLI Example:
salt '*' cron.rm_job root /usr/local/weekly salt '*' cron.rm_job root /usr/bin/foo dayweek=1
Remove cron environment variable for a specified user.
CLI Example:
salt '*' cron.rm_env root MAILTO
Remove a cron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match.
CLI Example:
salt '*' cron.rm_job root /usr/local/weekly
salt '*' cron.rm_job root /usr/bin/foo dayweek=1
Remove a special cron job for a specified user.
CLI Example:
salt '*' cron.rm_special root /usr/bin/foo
Set up an environment variable in the crontab.
CLI Example:
salt '*' cron.set_env root MAILTO user@example.com
Sets a cron job up for a specified user.
CLI Example:
salt '*' cron.set_job root '*' '*' '*' '*' 1 /usr/local/weekly
Set up a special command in the crontab.
CLI Example:
salt '*' cron.set_special root @hourly 'echo foobar'
Writes the contents of a file to a user's crontab
CLI Example:
salt '*' cron.write_cron_file root /tmp/new_cron
Changed in version 2015.8.9.
Note
Some OS' do not support specifying user via the crontab command i.e. (Solaris, AIX)
Writes the contents of a file to a user's crontab and return error message on error
CLI Example:
salt '*' cron.write_cron_file_verbose root /tmp/new_cron
Changed in version 2015.8.9.
Note
Some OS' do not support specifying user via the crontab command i.e. (Solaris, AIX)