问题描述
我正在尝试将 Amazon Lightsail 上的 crontab 作业设置为每天美国东部标准时间晚上 11:55 运行。该作业运行一个非常简单的 Python 脚本。作业执行,但改为在美国东部标准时间下午 6:55。我已经尝试在 crontab 中设置 CRON_TZ=America/New_York
,以及在 timedatectl 中将本地时间更改为 EST,但都没有更新运行 EST 的时间。
如何让我的工作在美国东部标准时间晚上 11:55 在 Lightsail 上运行?
这是我的 crontab 代码:
CRON_TZ=America/New_York
53 23 * * * /usr/bin/python3.6 /home/ubuntu/path-to-script/script.py
这是我的时区信息:
ubuntu@ip-###:~$ timedatectl
Local time: Wed 2021-01-06 10:24:42 EST
Universal time: Wed 2021-01-06 15:24:42 UTC
RTC time: Wed 2021-01-06 15:24:43
Time zone: America/New_York (EST,-0500)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
解决方法
假设您使用的是 Trusty (14.04),但在基于 linux 的系统中步骤应该类似。请尝试以下步骤:
sudo dpkg-reconfigure tzdata - follow the instructions to select Region/Country
sudo service cron restart
timedatectl - Verify your date settings
我在 AWs Developer Forum 上也发现了类似的帖子。