Rex::Commands::Cron - Simple Cron Management
获取主机的crontab任务:
task "listcron", "192.168.137.3", sub {
my @crons = cron list => "root";
my $r=\@crons;
#print Dumper($r);
foreach (@{$r}){
say $_->{'line'};
};
};
[root@node01 Rex]# rex listcron
[2017-05-06 22:15:09] INFO - Running task listcron on 192.168.137.3
*/10 * * * 5 sh /root/a1.sh
09 * * * 5 sh /root/t1.sh
08 * * * 3 sh /root/s1.sh
[2017-05-06 22:15:20] INFO - All tasks successful on all hosts
添加任务。
这个示例会添加一个在每天每小时的第 1,5,19,和40分钟运行的任务。
task "addcron", "192.168.137.3", sub {
cron add => "root", {
minute => "1,5,19,40",
command => 'sh /root/aa/t1.sh',
};
};
[root@node01 Rex]# rex addcron
node2:/root#crontab -l
*/10 * * * 5 sh /root/a1.sh
09 * * * 5 sh /root/t1.sh
08 * * * 3 sh /root/s1.sh
1,5,19,40 * * * * sh /root/aa/t1.sh
rex 管理定时任务
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
设置定时任务,别再写死了!动态定时任务真的太爽了!
设置定时任务,别再写死了!动态定时任务真的太爽了!
spring 触发器 cron表达式 -
定时任务管理
定时任务管理文章目录列表源码包管理定时任务的概念定时任务相关介绍定时任务案例定时
linux 定时任务 vim 时间同步