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.
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
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
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
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
Iv only noticed Cron issues in lxc lately, hope you solve your issue.
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
From memory there was a change a little while back with how cron handles the timezone.
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.
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.
This still confused me. I setup crontab items as above, but the running time in log:
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.
UTC
thanks a lot. after restarting crond the issue was resolved.