[Ansible]cron模块 计划任务

官网

该模块只能创建并管理的计划任务,不能被系统crontab -e 管理

  • name cronjob名字
  • minute 分钟 (Minute when the job should run ( 0-59, *, */2, etc ))
  • hour 小时 (Hour when the job should run ( 0-23, *, */2, etc ))
  • day 天 (Day of the month the job should run ( 1-31, *, */2, etc ))
  • month 月 (Month of the year the job should run ( 1-12, *, */2, etc ))
  • weekdad 星期几 (Day of the week that the job should run ( 0-6 for Sunday-Saturday, *, etc ))
  • job 内容或脚本
  • state present或absent
# 创建一个任务
ansible webservers -m cron -a "name='create new job' minute='0' job='ls -alh > /dev/null'"
[root@ceph3 yum.repos.d]# crontab -l
#Ansible: create new job
0 * * * * ls -alh > /dev/null

# 删除一个任务
ansible webservers -m cron -a "name='create new job' state=absent"

END

posted @ 2020-09-14 16:39  LeoShi2020  阅读(575)  评论(0编辑  收藏  举报