SaltStack 之 计划任务批量修改
一、通过salt修改从机Linux_Test的计划任务
[[email protected] salt]# vi crontab.sls
crontab: #脚本脚识
cron.present: #模板:cron 计划任务 功能:present
- name: /usr/sbin/ntpdate times.aliyun.com >> /dev/null #需要追回的内容
- user: root #添加到root的计划列表
- minute: ‘*/5‘ #每五分钟执行一次上面的-name命令
[[email protected] salt]# salt ‘Linux_Test‘ state.sls crontab
Linux_Test:
----------
ID: crontab
Function: cron.present
Name: /usr/sbin/ntpdate times.aliyun.com >> /dev/null
Result: True
Comment: Cron /usr/sbin/ntpdate times.aliyun.com >> /dev/null added to root‘s crontab
Started: 22:34:41.955076
Duration: 33.704 ms
Changes:
----------
root:
/usr/sbin/ntpdate times.aliyun.com >> /dev/null
Summary
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
备注:
分钟:minute
时钟:hour
日期:daymonth
月:month
周:dayweek
二、验证salt是否生效
[[email protected] salt]# salt ‘Linux_Test‘ cmd.run ‘crontab -l‘
Linux_Test:
# Lines below here are managed by Salt, do not edit
*/5 * * * * /usr/sbin/ntpdate times.aliyun.com >> /dev/null
原文地址:http://blog.51cto.com/12965094/2126827
时间: 2024-10-09 17:36:48