Work with cron
注解
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.
salt.modules.cron.
list_tab
(user)¶Return the contents of the specified user's crontab
CLI 范例:
salt '*' cron.list_tab root
salt.modules.cron.
ls
(user)¶This function is an alias of list_tab
.
Return the contents of the specified user's crontab
CLI 范例:
salt '*' cron.list_tab root
salt.modules.cron.
raw_cron
(user)¶Return the contents of the user's crontab
CLI 范例:
salt '*' cron.raw_cron root
salt.modules.cron.
rm
(user, cmd, minute=None, hour=None, daymonth=None, month=None, dayweek=None, identifier=None)¶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 范例:
salt '*' cron.rm_job root /usr/local/weekly salt '*' cron.rm_job root /usr/bin/foo dayweek=1
salt.modules.cron.
rm_env
(user, name)¶Remove cron environment variable for a specified user.
CLI 范例:
salt '*' cron.rm_env root MAILTO
salt.modules.cron.
rm_job
(user, cmd, minute=None, hour=None, daymonth=None, month=None, dayweek=None, identifier=None)¶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 范例:
salt '*' cron.rm_job root /usr/local/weekly
salt '*' cron.rm_job root /usr/bin/foo dayweek=1
salt.modules.cron.
rm_special
(user, special, cmd)¶Remove a special cron job for a specified user.
CLI 范例:
salt '*' cron.rm_job root @hourly /usr/bin/foo
salt.modules.cron.
set_env
(user, name, value=None)¶Set up an environment variable in the crontab.
CLI 范例:
salt '*' cron.set_env root MAILTO user@example.com
salt.modules.cron.
set_job
(user, minute, hour, daymonth, month, dayweek, cmd, commented=False, comment=None, identifier=None)¶Sets a cron job up for a specified user.
CLI 范例:
salt '*' cron.set_job root '*' '*' '*' '*' 1 /usr/local/weekly
salt.modules.cron.
set_special
(user, special, cmd)¶Set up a special command in the crontab.
CLI 范例:
salt '*' cron.set_special root @hourly 'echo foobar'
salt.modules.cron.
write_cron_file
(user, path)¶Writes the contents of a file to a user's crontab
CLI 范例:
salt '*' cron.write_cron_file root /tmp/new_cron
salt.modules.cron.
write_cron_file_verbose
(user, path)¶Writes the contents of a file to a user's crontab and return error message on error
CLI 范例:
salt '*' cron.write_cron_file_verbose root /tmp/new_cron