Ansible 定时任务模块cron、修改主机名字模块hostname(学习笔记十二),ansiblecron


1、新增一个定时任务:
ansible all -m cron -a "name=check minute=5 job='pwd'"

img_4b95538783c656818bb0dfd3f9e73136.png image.png

2、删除定时任务:
ansible all -m cron -a "name=check state=absent"

3、把这个定时任务存放在/etc/cron.d/目录下的某一个自定义文件中:
ansible all -m cron -a "name=check minute=5 job='pwd' user='root' cron_file='testcronfile'"


img_b3cc0f0c8c263431a0ab2dee6bdc92a4.png image.png

4、定时任务的参数还包括:day,hour,month,weekday,state(任务启用或停止),reboot(重启后是否需要执行,默认为否)

5、修改主机名字:hostname
ansible 172.16.52.245 -m hostname -a "name=ansible-test245"

相关内容