gjcarneiro / yacron

A modern Cron replacement that is Docker-friendly
MIT License
449 stars 38 forks source link

wrong task start time(due to UTC) #17

Closed Karmashkin closed 6 years ago

Karmashkin commented 6 years ago

yacron run inside docker alpine 3.6 based python 3.6.1 timezone(America/Montreal) in the container and on the host is the same.

jobs:
- name: everydayat1
  command: python3 -u /xxx/xxxx/xxxx/xxxx.py
  schedule: "0 1 * * *"

but task start at 20:00 the previous day.

go to source https://github.com/gjcarneiro/yacron/blob/master/yacron/cron.py and see

def get_now() -> datetime.datetime:
return datetime.datetime.utcnow()

goto container with yacron, run python

# python3
Python 3.6.1 (default, Oct  2 2017, 20:46:59) 
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
»> import datetime
»> datetime.datetime.utcnow()
datetime.datetime(2017, 12, 21, 10, 13, 3, 834821)
»> datetime.datetime.now()
datetime.datetime(2017, 12, 21, 5, 13, 28, 419075)

is it possible to add a setting to the Tasks UTC = 1 UTC = 0 ?

thank you for your time, sincerely.

gjcarneiro commented 6 years ago

Yes, you're right.

Rats, I remember when developing this I started using UTC without thinking much, just to simplify things, but meant to revisit the issue later. Eventually I forgot. I think localtime by default makes more sense, but it's probably a bad idea to change the default now :(

Yes, I think we need a new setting.