Server time

Ask questions about dedicated servers here and we and other users will do our best to answer them. Please also refer to the self-help section for tutorials and answers to the most commonly asked questions.
Post Reply
mainedan
A regular
A regular
Posts: 39
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sun Oct 27, 2013 9:34 pm

Server time

Post by mainedan »

My VDS server time is off 4 hours, I have run sudo dpkg-reconfigure tzdata and the zones are correct. But the output it gives is

Current default time zone: 'America/New_York'
Local time is now: Mon May 30 09:47:59 EDT 2016.
Universal Time is now: Mon May 30 13:47:59 UTC 2016.

The current time was 13:47 for my local time.

This is affecting plugins on my procon install (Adkats)
mainedan
A regular
A regular
Posts: 39
Joined: Sun Oct 27, 2013 9:34 pm

Re: Server time

Post by mainedan »

Figured it out, had to do timedatectl set-ntp 0 before the timedatectl set-time [TIME] command
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Server time

Post by Edge100x »

It is possible that your OS was not correctly assuming that the hardware clock was set to localtime (instead of UTC). So that it works after a reboot, you may need to use this command to write that it is LOCAL to /etc/adjtime:

Code: Select all

hwclock --localtime --systohc
Then, shut down the VDS entirely (shutdown -h now) and start it back up through the control panel, and it should have the correct starting time (the system time of the machine hosting the VDS, which also runs ntpd).
mainedan
A regular
A regular
Posts: 39
Joined: Sun Oct 27, 2013 9:34 pm

Re: Server time

Post by mainedan »

when I do that i get this error
Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
I thought I had it figured out with the help desk, it was working ok, i needed to do a restart, now it went back.
mainedan
A regular
A regular
Posts: 39
Joined: Sun Oct 27, 2013 9:34 pm

Re: Server time

Post by mainedan »

Thing is, I tested a Server someplace else plus a test server at my house, and had no issues with this. I am not sure if it is my settings on the vds, or the control panel. Or if it is on the main box itself. It wouldn't matter so much if it didn't mess with the procon plugins that require time sync. Im not sure if I moved to a different box if that would fix it or no. Been 2 weeks trying to get it sorted out.
mainedan
A regular
A regular
Posts: 39
Joined: Sun Oct 27, 2013 9:34 pm

Re: Server time

Post by mainedan »

this is what it looks like with the "Use a local system clock instead of UTC" is unchecked in the Advanced options:

Code: Select all

timedatectl
      Local time: Wed 2016-06-01 17:07:37 EDT
  Universal time: Wed 2016-06-01 21:07:37 UTC
        RTC time: Wed 2016-06-01 21:07:37
       Time zone: America/New_York (EDT, -0400)
 Network time on: no
NTP synchronized: yes
 RTC in local TZ: no
and this is when it is checked

Code: Select all

timedatectl
      Local time: Wed 2016-06-01 17:16:29 EDT
  Universal time: Wed 2016-06-01 21:16:29 UTC
        RTC time: Wed 2016-06-01 21:16:29
       Time zone: America/New_York (EDT, -0400)
 Network time on: no
NTP synchronized: yes
 RTC in local TZ: no
this is 4 hours behind the correct time
mainedan
A regular
A regular
Posts: 39
Joined: Sun Oct 27, 2013 9:34 pm

Re: Server time

Post by mainedan »

I did a fresh install, checked the timedatectl and it was off 4 hours, did what you had suggested edge, still off 4 hours. Did this 'timedatectl set-local-rtc 0' and unchecked Use a local system clock instead of UTC. Now it is correct even after reboot.

Code: Select all

timedatectl
      Local time: Wed 2016-06-01 22:07:51 EDT
  Universal time: Thu 2016-06-02 02:07:51 UTC
        RTC time: Thu 2016-06-02 02:07:50
       Time zone: America/New_York (EDT, -0400)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no
This is the corrct time.
Going to see where it sits tomorrow morning, reboot again and test again. Kinda aggravating though. :/
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Server time

Post by Edge100x »

You have two options.

1. Use local time, which is set by default in our control panel. Make sure that the Linux system is set to use it. On Ubuntu 16.04, the command that I gave will accomplish that.
2. Use UTC, which is another option in our control panel. Make sure that the Linux system is set to use UTC.

Either will work. It sounds like your flavor of Linux prints a scary message if you use #1, but you can ignore that message, because the time that it's reading is properly synced and corrected -- it's not something that the BIOS is (poorly) maintaining, as they assume. #2 works just fine, too, if you'd rather just stick with UTC.

With either, you can also set whatever time zone you want inside your VDS, but, if you are using option #1 and wish to use anything other than the hosting machine's time zone (Eastern if it is in NYC, for instance), you'll also need to use the adjuster on the "Advanced" section of the "Server control" page to correct it to what you want.

Servers here start with #1, because that's all that Windows supports. We want to keep things standard, and Linux supports both.

When you fiddle with the time and reboot the VDS, make sure to also do a full shutdown (such as with "shutdown -h now"), as I mentioned previously. If you do a soft reboot (such as "reboot"), it won't catch changes made to the "Server control" page, and might also behave differently if your OS is trying to set the RTC.
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Server time

Post by Edge100x »

Also, yes, this is a scenario unique to virtualized machines. On a regular full machine, your OS can set the RTC (hardware clock) to whatever it wants, and nothing else will touch it; so, it can reliably assume that it will still be set correctly after a reboot. On a virtual machine, the hardware clock is maintained by the hypervisor (Xen, in this case) and can't actually be changed, just read, because it is system-wide.

As long as the control panel and your OS are set to the same assumption of what time to use, you're good to go.
mainedan
A regular
A regular
Posts: 39
Joined: Sun Oct 27, 2013 9:34 pm

Re: Server time

Post by mainedan »

the shutdown -h now command might have been useful when adjusting the advanced settings, everyone said reboot, until you said it. Guess I still have a lot to learn.

Thanks
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Server time

Post by Edge100x »

Using the "Turn on" or "Reboot" action will cause the changes on the "Server control" page to take effect. It also mentions this after submission.

The "Reboot" action on the page is different from typing "reboot" in the console. I will try to think of a way to make that more clear.
Post Reply