The incron state module allows for user incrontabs to be cleanly managed.
Incron declarations require a number of parameters. The parameters needed
to be declared: path
, mask
, and cmd
. The user
whose incrontab is to be edited
also needs to be defined.
When making changes to an existing incron job, the path
declaration is the unique
factor, so if an existing cron that looks like this:
Watch for modifications in /home/user:
incron.present:
- user: root
- path: /home/user
- mask:
- IN_MODIFY
- cmd: 'echo "$$ $@"'
改变它成为这样:
Watch for modifications and access in /home/user:
incron.present:
- user: root
- path: /home/user
- mask:
- IN_MODIFY
- IN_ACCESS
- cmd: 'echo "$$ $@"'
存在的cron 将被更新掉,但是如果计划任务内容有改变,那么一个新的cron 将被添加到用户的crontab里面。
0.17.0 新版功能.
salt.states.incron.
absent
(name, path, mask, cmd, user='root')¶Verifies that the specified incron job is absent for the specified user; only the name is matched when removing a incron job.
salt.states.incron.
present
(name, path, mask, cmd, user='root')¶Verifies that the specified incron job is present for the specified user.
For more advanced information about what exactly can be set in the cron
timing parameters, check your incron system's documentation. Most Unix-like
systems' incron documentation can be found via the incrontab man page:
man 5 incrontab
.