标签:host rip init keyword let back level file dev
日志清理目前覆盖58台服务器如下
此处省略
[root@BS003 backup]# ansible 192.168.16.211 -m fetch -a ‘src=/data/home/deploy/output/logs/backup_MC005.tar.gz dest=/tmp/backup‘
[root@BS003 log]# ansible 192.168.16.211 -m file -a ‘path=/data/home/deploy/output/logs/backup_MC005.tar.gz state=absent‘
0 2 * * * /bin/sh /server/scripts/log.sh 每天凌晨2点进行清理日志和备份
0 3 * * * /bin/bash /server/scripts/cront_pull.sh
0 4 * * * /bin/bash /server/scripts/cront_delete.sh
ansible-ploybook
- hosts: log
tasks:
- name: copy file shell
copy:
src: /server/scripts/probject/log.sh
dest: /server/scripts
mode: 0755
- name: Delete log regularly
cron:
minute: 0
hour: 2
day: \*
month: \*
weekday: \*
name: Delete log regularly
job: /bin/bash /server/scripts/log.sh
从远端拉取tar包到本地
ansible 192.168.16.210 -m fetch -a ‘src=/home/deploy/backup_MC004.tar.gz dest=/tmp/backup‘
删除远端tar包
ansible 192.168.16.210 -m file -a ‘path=/data/home/deploy/output/logs/backup_MC004.tar.gz state=absent‘
标签:host rip init keyword let back level file dev
原文地址:https://www.cnblogs.com/sseban/p/13048106.html