SaltStack使用教程(三):定时任务管理cron.present
查看定时任务存在的形式:# cd /var/spool/cron/
# ls
bairoot
# ll
total 8
-rw------- 1 baibai 22 Sep 30 15:17 bai #这是bai这个用户的定时任务文件,600权限
-rw------- 1 root root 146 Sep 30 14:56 root
下面编写状态文件
# vim test.sls
/var/spool/cron/bai:
file.managed:
- source: salt://crontab/files/saltstack-node2.example.com.bai
- mode: 600
- user: bai
- group: bai
执行状态
# salt 'saltstack-node2.example.com' state.highstate
saltstack-node2.example.com:
----------
ID: /var/spool/cron/bai
Function: file.managed
Result: True
Comment: File /var/spool/cron/bai updated
Started: 15:40:33.193250
Duration: 57.914 ms
Changes:
----------
diff:
---
+++
@@ -1,0 +1,1 @@
+* * * * * echo "hello world"
Summary
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
查看定时任务已创建
# salt 'saltstack-node2.example.com' cron.raw_cron bai
saltstack-node2.example.com:
* * * * * echo "hello world"
You have new mail in /var/spool/mail/root
页:
[1]