报错:
[root@jenkins ~]# ansible go_activity -m cron -a "name=‘log_clear‘ minute=0 hour=2 job=find /home/golanger/log/ -type f -name ‘log$(date +\%d -d -1day)‘ -delete"
ERROR! this task ‘cron‘ has extra params, which is only allowed in the following modules: command, win_command, shell, win_shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta
解决:
这个需要在job上加引号,另外如下,如果有一些特殊符号的话,需要转义
[root@jenkins ~]# ansible go_activity -m cron -a "name=log_clear minute=0 hour=2 job=‘find /home/golanger/log/ -type f -name \"log\$(date +%d -d -1day)\" -delete‘"
虽然加了计划任务,但是还是需要删除下今天的日志,手动执行
[root@jenkins ~]# ansible go_weiai_project -m shell -a "find /home/golanger/log/ -type f -name \"log\$(date +%d -d -1day)\" -delete"
原文地址:http://blog.51cto.com/zhangdl/2351762
时间: 2024-10-18 15:02:35