将Amazon Lightsail中的crontab任务设置为EST

2024-07-05 14:01:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在亚马逊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

Tags: newtimeubuntu作业时间scriptcrontz
1条回答
网友
1楼 · 发布于 2024-07-05 14:01:45

假设您使用的是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上也发现了类似的线程

相关问题 更多 >