我似乎找不到对crontab的CRON_TZ设置的支持。如何将ansible配置为针对特定时区运行cron作业?
这就是我想要的crontab文件的样子。此cron配置当前在CentOS 7计算机上运行。
/etc/crontab:
# Default Timezone
30 9 * * * bobr /home/bobr/crontest.sh LOCAL "`date -R`"
CRON_TZ=Canada/Eastern
30 11 * * * bobr /home/bobr/crontest.sh Eastern "`date -R`"
45 11 * * * bobr/home/bobr/crontest.sh Eastern "`date -R`"
CRON_TZ=Canada/Pacific
30 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"
44 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"作为参考,crontest.sh只会发送一封包含以下两个参数的电子邮件:
#!/bin/bash
echo "this is the cron test. $1 $2" | mail -s "Cron Test" bobr@example.com发布于 2019-11-02 00:51:44
在可能的CRON模块中找不到时区设置的任何属性。也许你可以尝试其他方法..使用shell..
- name: configure cron using shell
shell: crontab cron.conf和conf文件是
cat cron.conf
# Default Timezone
30 9 * * * bobr /home/bobr/crontest.sh LOCAL "`date -R`"
CRON_TZ=Canada/Eastern
30 11 * * * bobr /home/bobr/crontest.sh Eastern "`date -R`"
45 11 * * * bobr/home/bobr/crontest.sh Eastern "`date -R`"
CRON_TZ=Canada/Pacific
30 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"
44 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"https://stackoverflow.com/questions/58662645
复制相似问题