Sunday, July 24, 2016

Time drift in Arch Linux

Have you ever looked at the clock on your computer, then looked at the clock on your mobile device and wondered why they differed?  The easy answer is time drift.  The realtime clock (RTC) in your computer, as well as mobile devices like smartphones, tablets, laptops, watches, etc operates on its own timeframe.  It does not conform to any universal standard.  This is why utilities such as NTP and timedatectl were created.

The timedatectl utility is specifically designed for Arch Linux as an easy-to-use utility for the Network Time Protocol (NTP), but NTP is generally controlled a bit more directly in Ubuntu, Redhat and other distributions.  I'm going to focus on timedatectl for this particular entry.

First, open up a terminal.


Next, let's get an idea of what's currently going on with the time and date situation.  Just run the following command:

timedatectl status


This tells you the various times, which timezone you're set to, whether the network time is on, if NTP is turned on and whether or not the RTC is set to the local TimeZone.  Since we want to correct for time drift, let's get NTP synchronized.  In order to do that, we need to turn Network time on.  Let's start by checking out our options.


There is a set-ntp option.  It states that it needs a BOOL, or boolean, which can be one of two different entries.  In this case, 'yes' and 'no' are a pair of very human conditions that we can work with.  It is important to perform this function as a standard user.  It will ask you to authenticate.  This is for security purposes.


Once that is completed, you can check to see the current status.


Now, the Network time is set to 'on', and all three clocks are set to the current time.  This should reflect from other devices as well.

By maintaining the current time on your desktop or portable computer, you can avoid delays.  Happy time!