Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

python - Setting crontab task in Amazon Lightsail to EST

I'm trying to set a crontab job on Amazon Lightsail to run at 11:55 PM EST, daily. The job runs a pretty simple Python script. The job executes, but at 6:55 PM EST instead. I've tried setting both CRON_TZ=America/New_York within crontab, as well as changing the local time to EST within timedatectl, but neither updates the time to run EST.

How can I get my job to run at 11:55 PM EST on Lightsail?

Here is my crontab code:

CRON_TZ=America/New_York

53 23 * * * /usr/bin/python3.6 /home/ubuntu/path-to-script/script.py

and here is my time zone information:

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
question from:https://stackoverflow.com/questions/65598580/setting-crontab-task-in-amazon-lightsail-to-est

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Assuming you are using Trusty (14.04) but steps should be similar in linux based systems. Try the following steps:

sudo dpkg-reconfigure tzdata - follow the instructions to select Region/Country
sudo service cron restart
timedatectl - Verify your date settings

I found similar thread on AWs Developer Forum as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...