码迷,mamicode.com
首页 > 其他好文 > 详细

ansible之cron模块

时间:2018-03-05 11:13:14      阅读:1481      评论:0      收藏:0      [点我收藏+]

标签:ansible之cron模块

例:在指定节点上定义一个计划任务,每隔3 分钟到主控端更新一次时间

[root@master ~]# ansible all -m cron -a ‘name="date" minute=*/3 hour=* day=* month=*
weekday=* job="/usr/sbin/ntpdate 10.0.0.28"‘

paramiko: The authenticity of host ‘master.test.com‘ can‘t be established.
The ssh-rsa key fingerprint is 3d906ef1d450e4cc7031aef5e8c296f6.
Are you sure you want to continue connecting (yes/no)?
agent.test.com | SUCCESS => {
"changed": false,
"envs": [],
"jobs": [
"date"
]
}
client02 | SUCCESS => {
"changed": false,
"envs": [],
"jobs": [
"date"
]
}

master.test.com | UNREACHABLE! => {
"changed": false,
"msg": "Authentication failed.",
"unreachable": true
}

[root@client01 tmp]# crontab -l
#Ansible: date
*/3 * * * * /usr/sbin/ntpdate 10.0.0.28
[root@client02 tmp]# crontab -l
#Ansible: date
*/3 * * * * /usr/sbin/ntpdate 10.0.0.28

删除刚才新建的定时任务

ansible all -m cron -a ‘name="date" state=absent‘

ansible之cron模块

标签:ansible之cron模块

原文地址:http://blog.51cto.com/wujianwei/2082892

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!