How to Set Clock Time and Date on Ubuntu Server when NTP Synchronized is set to No

In the event your Ubuntu server has an incorrect time, we want to ensure our end users can log into the server or OpenVPN successfully. Sometimes, especially if OpenVPN is in use, their login is dependent on the time of the server being correct. 

First issue the command:

date

Looking at our cell phone we can see this time is off by about 45 seconds; the date display in the above screenshot shows the Day, Date, Hours, Minutes, Seconds, TimeZone and Year. 

Let’s check to see if our clock is set to be synchronized. Do this by issuing the command:

timedatectl status

Here we see that our “NTP synchronized: no” status indicates our Network Time Protocol synchronization is turned off. 

In order to get our clock synchronized and change it to NTP synchronized: yes we need to do the following.

  1. Stop the ntp service
  2. Sync the time using ntpd with the -g and -q switches (allows the time to be set without restriction)
  3. Start the ntp service

We can do this by issuing the commands: 

Sudo service ntp stop
Sudo ntpd -gq

This will produce something like the following output:

In this output we can see that our time was offset and adjusted by -49.77 seconds.

Next let’s start the ntp service again with the command:

Sudo service ntp start

Lastly we can confirm that our time is set correctly and that NTP synchronized: is now set to yes with the command:

timedatectl

That should do it! You can now have your OpenVPN users log in. If they continue to have issues, check out the article on Troubleshooting OpenVPN

If this article helped you, please click on an ad to help pay for hosting and site upgrades. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *