1

I have a Centos machine with version 7. I am trying to change the system time using the timedatectl command. The time gets changed but after a few seconds it gets reset back to it's original time.

[root@abcd ~]# timedatectl
  Local time: Tue 2018-10-16 05:51:30 UTC
  Universal time: Tue 2018-10-16 05:51:30 UTC
  RTC time: Wed 2019-10-16 03:40:38
  Time zone: UTC (UTC, +0000)
  NTP enabled: no
  NTP synchronized: no
  RTC in local TZ: no
  DST active: n/a
[root@abcd ~]#
[root@abcd ~]# timedatectl set-time "2019-10-16 05:51:30"
[root@abcd ~]# timedatectl
  Local time: Wed 2019-10-16 05:51:32 UTC
  Universal time: Wed 2019-10-16 05:51:32 UTC
  RTC time: Wed 2019-10-16 05:51:33
  Time zone: UTC (UTC, +0000)
  NTP enabled: no
  NTP synchronized: no
  RTC in local TZ: no
  DST active: n/a
[root@abcd ~]# timedatectl
    Local time: Tue 2018-10-16 05:54:38 UTC
    Universal time: Tue 2018-10-16 05:54:38 UTC
    RTC time: Wed 2019-10-16 05:52:35
    Time zone: UTC (UTC, +0000)
    NTP enabled: no
    NTP synchronized: no
    RTC in local TZ: no
    DST active: n/a
[root@abcd ~]#

When I check the systemd logs using journalctl -f command, I notice that there is a process which is changing the system time to UTC after 80 sec approximately. I have no clue what this process is. Those logs are

Oct 16 06:01:39 abcd systemd[1]: Time has been changed
Oct 16 06:02:58  abcd systemd[1]: Time has been changed

How do I debug this ?

alexander.polomodov
  • 1,068
  • 3
  • 10
  • 14
user1851006
  • 141
  • 2
  • 3

2 Answers2

3

just try setting timezone.

# timedatectl set-timezone *your timezone*
aroN
  • 75
  • 1
  • 8
  • You are setting the time. You need to set the timeZONE as @aroN indicates. Alternatively, you can change the timezone by deleting `/etc/localtime` and creating it as a new symlink as here: `~ 0$ ls -l /etc/localtime` `lrwxrwxrwx. 1 root root 27 Sep 7 12:57 /etc/localtime -> /usr/share/zoneinfo/MST7MDT` – UtahJarhead Oct 16 '18 at 13:38
  • Changing timezone doesn't work either. If I change the timezone to say, CDT, it sets it back to UTC after 80 sec. I want to know which process/daemon is doing this – user1851006 Oct 16 '18 at 17:20
1

If this is a virtual guest, some guest integrations sync the time of the host to the guest. Check that the hypervisor is syncing time with NTP, so this time is at least correct.

If you want to run in the wrong time for some reason, please edit your question to add why, and which virtual platform you use.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34