TAGS :Viewed: 4 - Published at: a few seconds ago

[ update VM time periodically ]

I have a linux (debian) VM and I need it to run with he UTC time, but for some reason the clock gets out of time in a matter of days.

I don't know if the VM clock runs slower, faster, or gets updated at a certain moment.

It is a VM on a VMware server of virtual machines. I access the VM remotely. And I don't have access to the server.

I tried using ntpd and similar, but the hour ends up changed at the next day.

I only need a 5 minutes precision. UTC time +/- 5 minutes

So I wanted to know if I can make some sort of script that gets executed every hour that updates the date of the VM to the UTC time.

Answer 1


1- Install ntp or openntpd - (I use ntp)

2- edit /etc/ntp.conf and be sure there is at least one server

3- start the service ntpd and config to run every time you turn on the PC with:

systemctl enable ntpd systemctl start ntpd systemctl status ntpd

Last line is to be sure that the service is running

4- run timedatectl and check if the timezone and the autoadjust by ntp is true. You can run timedatectl --set-ntp 1 to activate it. the time now is update frecuently.

5- check man timedatectl to see other options like UTC time clock and timezone.