How can i start ntpd -qg on startup?

Hello, i am a new linux user and the system clock is off by an hour. I did some googling and found a package called ntpd. When i run the command “sudo ntpd -qg” it fixes my clock. How can i run this on startup, so that I don’t have to keep typing it in manually?


Welcome to the forum!

ntpd is one option, but the more common way of doing it in systemd-based distributions is to use systemd-timesyncd.service, which is already installed by default. :arrow_down:

sudo systemctl enable --now systemd-timesyncd.service

This will both start it and enable it to automatically start at boot time.

Incidentally, the problem of your clock being an hour off is most likely caused by the fact that you’re dual-booting with Microsoft Windows.

GNU/Linux prefers to store the time in the hardware clock as UTC, but Windows stores it as local time, and so after having rebooted from Windows into GNU/Linux, your system clock will be off. You can tell GNU/Linux to store the hardware clock in local time instead of UTC, or do the opposite in Windows, but the latter is more difficult — it involves diving into the Windows Registry — even though it is the preferred way. :arrow_down:

1 Like

I used to have windows, but I completely wiped my drive and installed linux.

In that case, simply enter your UEFI settings and set your hardware clock to UTC instead of to your local time. :wink:

From the desktop terminal:

hwclock -h

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.