0

In centos7, I don't know why the date are showing different timestamp. When I modified according to my need and rebooted the machine, it is getting reset. Tried most of the options as I got in different forums (e.g., hwclock -s, rm -rf /etc/adjtime etc).

[root@mymachine ~]# date
Thu Oct 20 09:23:34 UTC 2016

[root@mymachine ~]# hwclock
Thu 20 Oct 2016 11:24:02 AM UTC  -0.302003 seconds

In some forum, people suggested vmware tools, vm can made this change. But when I checked, timesync is in disabled state.

[root@mymachine ~]# /usr/bin/vmware-toolbox-cmd timesync status
Disabled

So really not sure what is causing the date to reset or from when it has been taken?

[root@mymachine ~]# timedatectl status
      Local time: Thu 2016-10-20 09:25:47 UTC
  Universal time: Thu 2016-10-20 09:25:47 UTC
        RTC time: Thu 2016-10-20 11:26:12
        Timezone: n/a (UTC, +0000)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

If I manually set the time with timedatectl set-time HH:MM:ss it will change system clock and hardware clock. upon reboot hardware clock stays true to what I set up last time with timedatectl set-time HH:MM:ss but system clock reverts back as if I hadn't manually set the time.

3
  • @david-hofmann : Can you check if your system automatically calls hwclock --hctosys at init time and hwclock --systohc at shutdown time ?
    – MC68020
    Commented Nov 26, 2022 at 21:41
  • Since the user who offered the bounty no longer gets enough credit to comment and I do not hold enough power to allow by myself the edit they made of the OP, I reproduce hereafter @david-hofman 's complements of information :
    – MC68020
    Commented Nov 27, 2022 at 14:22
  • If I manually set the time with timedatectl set-time HH:MM:ss it will change system clock and hardware clock. upon reboot hardware clock stays true to what I set up last time with timedatectl set-time HH:MM:ss but system clock reverts back as if I hadn't manually set the time. (copied on behalf of @david-hofmann)
    – MC68020
    Commented Nov 27, 2022 at 14:24

4 Answers 4

2

Check the system bios time. If the bios time is same with OS time after reboot change the time from BIOS setup. Also, check the time zone settings you are using.

Another situation can be the CMOS Battery is not functional, if your PC is very old this may be the reason.

0

Hardware clock (hwclock) may be set to UTC time or local time (local mostly when you are or not using Windows on the same computer), then BIOS/CMOS have one time and working system have other time.

What I would do is to issue command:

sudo dpkg-reconfigure tzdata

and wisely select the proper timezone. Also you could search for settings that say that your hardware clock is set to local time or UTC time and change this setting. Mostly this setting is set at Linux installation.

Look here:

https://serverfault.com/questions/496076/how-to-set-hwclock-to-utc

0

Hardware BIOS/CMOS clock may be the issue. Try shutting off the PC, unplugging your PC and then plugging it back in to see if the time goes off track. If so then it is the CMOS Battery and it needs replaced.

-1

It is possible that the clock synchronization service is not running correctly on your system. To check this, you can use the timedatectl command:

timedatectl status

If the output shows that NTP is enabled and synchronized, then the clock synchronization service is running.

If NTP is not synchronized, then you may need to manually set the time. To do this, run the following command:

timedatectl set-time HH:MM:ss

Replace HH:MM:ss with the desired time.

If the NTP synchronization is not enabled, you can enable it with the following command:

timedatectl set-ntp yes

Once the NTP synchronization is enabled, you should be able to reboot your system without losing the time settings.

1
  • Note that ChatGPT-generated text must abide by the ChatGPT usage requirements, which includes that you may not "represent that output from the Services was human-generated when it is not". We also have a policy disallowing AI-generated answers in general (see here).
    – Kusalananda
    Commented Mar 11, 2023 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .