1、在控制节点上执行:cat /etc/ansible/hosts,查看受控主机清单
2、执行shell命令:
ansible swarm -m shell -a "cd /export/home/spider/aves_spider_logs/;find . -maxdepth 1 -type d -mtime +12 |xargs -n 1 rm -rf "
3、执行定时任务:可以到每个节点上执行crontab -l进去确认
ansible swarm -m cron -a 'name="ban IP of login" minute=*/1 hour=* day=* month=* weekday=* job="cd /export/home/spider/aves_spider_logs/;find . -maxdepth 1 -type d -mtime +11"'
4、 删除定时任务:
ansible swarm -m cron -a 'name="ban IP of login" state=absent'