Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


KVM's time in crontab issue
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

KVM's time in crontab issue

frakassfrakass Member

Hello

I found my crontab works not correctly. It just follow the timezone in its physical host.
For instance, I specify the time zone to my location (EU), while the physical host is in USA.
Then my crontab won't follow the correct time to run, but use the time in USA timezone.

How can I fix this? I am using the VPS from a big platform from the US

Thanks

Comments

  • LisoLiso Member

    Can you describe how do you specify the time zone to my location, I think there's a misconfiguration. Mine works just fine and follows my local timezone (ID).

  • how do you set the timezone?

    I usually put the timezone before the crontab job
    ex

    TZ=Australia/Sydney

            • my command
  • i setup this item in crontab:

    0 0 * * * /home/xxx/bin/auto-backup.sh

    But this item doesn't run at 00:00.
    instead it run at 08:00 of my host time.
    (So I was thinking my 08:00 is might be the physical host 00:00)

    so how?

  • For debian, you could try dpkg-reconfigure tzdata

    Thanked by 2caracal yoursunny
  • Iv only noticed Cron issues in lxc lately, hope you solve your issue.

  • @sanvit said:
    For debian, you could try dpkg-reconfigure tzdata

    i already setup this to my timezone. I certainly won't setup it to the US TZ.

  • That might sound wild, but you can do the conversion yourself and run the cronjob at the exact time within your US servers timezone to match your EU timezone :wink:

    Thanked by 1Falzo
  • From memory there was a change a little while back with how cron handles the timezone.

  • edited April 2022

    Does
    hwclock --show

    show the same time as

    date
    ?

    EDIT: If they are not the same do
    hwclock --systohc --localtime

    Thanked by 1frakass
  • @FrankZ said:
    Does
    hwclock --show

    show the same time as

    date
    ?

    EDIT: If they are not the same do
    hwclock --systohc --localtime

    I have checked they are exactly the same. so my issue still exists. :)

    Thanked by 2FrankZ FrankZ
  • jeghjegh Member

    @Pilotseye said:
    That might sound wild, but you can do the conversion yourself and run the cronjob at the exact time within your US servers timezone to match your EU timezone :wink:

    I don't think that's a good idea. The switch to daylight saving time is not synchronized between US and EU, so you will have 2 weeks in March and 1 week in November when the cronjob is off by 1 hour.

  • Thanked by 1FrankZ
  • 0 0 * * * /home/pyh/bin/auto-backup.sh
    

    This still confused me. I setup crontab items as above, but the running time in log:

    04/05/22 08:00:03 - data backup begin
    04/05/22 08:08:04 - data backup end

    They have 8 hours difference. :) any further idea?

  • Have you restarted server or crontab daemon after you adjusted timezone?
    If not - then it's still using old timezone, from the boot.

    Thanked by 2frakass FrankZ
  • UTC

  • @JabJab said:
    Have you restarted server or crontab daemon after you adjusted timezone?
    If not - then it's still using old timezone, from the boot.

    thanks a lot. after restarting crond the issue was resolved.

Sign In or Register to comment.