管理定时任务
Manage cron jobs.
选项 ;
ensure -- 定义cron entry 的状态,正确的参数是present,absent
Manage cron entries.
添加一个cron任务:
cron_entry "reload-httpd",
ensure => "present",
command => "/etc/init.d/httpd restart",
minute => "1,5",
hour => "11,23",
month => "1,5",
day_of_week => "1,3",
day_of_month => "1,3,5",
user => "root",
on_change => sub { say "cron added"; };
# remove an entry
cron_entry "reload-httpd",
ensure => "absent",
command => "/etc/init.d/httpd restart",
minute => "1,5",
hour => "11,23",
month => "1,5",
day_of_week => "1,3",
day_of_month => "1,3,5",
user => "root",
on_change => sub { say "cron removed."; };
=cut
task "manage_cron", sub{
cron_entry "date",
ensure =>"present",
command =>"date",
minute => "1"
};
task "manage_cron", sub{
cron_entry "date",
ensure => "present",
command => "date",
minute => "1",
hour => '*',
day_of_month => '*',
day_of_week => '*',
user => 'root',
on_change => sub { say "cron added"; };
};
1 * * * * date