How to Fix Time Not Synchronized on Ubuntu Server

In this guide you will learn how to fix not synchronize time on Ubuntu server within the Amazon EC2 instance. This problem occurred in my EC2 Ubuntu server for the first time. I created a quick guide tutorial for this issue and I want other developers and SysAdmin can benefits from this guide.

I saw an error message upon checking on the /var/log/syslog.

Failed to call CloudWatch: HTTP 400. Message: Signature expired: 20190805T125458Z is now earlier than 20190805T125501Z (20190805T130001Z - 5 min.)Copy

Noticing the problem and found out was the system clock issue with more than 5 mins laps time delayed. Then, I’m trying to find a solution on the internet, and I found a great solution for fixing the system clock issue. The solution is you will need to install a Crony client.

Chrony is a versatile implementation of the Network Time Protocol (NTP). It can synchronize the system clock with NTP servers, reference clocks (e.g. GPS receiver), and manual input using wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) server and peer to provide a time service to other computers in the network. 

To get started, this guide will show you through step process on how to installing Chrony in Ubuntu server:

Step 1. Install Chrony

Remote SSH into your Amazon EC2 Ubuntu server and update your system repository packages using:

sudo apt updateCopy

To install Chrony, type command:

sudo apt install chrony -yCopy

Step 2. Configure Chrony

Open the chrony configuration file and modify using the command.

sudo vim /etc/chrony/chrony.confCopy

Add the line below before on the pool statement:

server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4Copy

The configuration something like this:

Not Synchronize Time on EC2 Ubuntu

Next, restart the Crony service using the command:

sudo /etc/init.d/chrony restartCopy

The command output looks like:

[ ok ] Restarting chrony (via systemctl): chrony.service.Copy

Step 3. Verify Chrony

Now verify that Chrony is using the IP address (169.254.169.123) and validate the time of synchronization metrics reported. Run the command:

chronyc trackingCopy

The output something like this:

Reference ID    : 169.254.169.123 (169.254.169.123)
Stratum         : 4
Ref time (UTC)  : Mon Aug  5 15:10:08 2019
System time     : 0.000003625 seconds fast of NTP time
Last offset     : +0.000004195 seconds
RMS offset      : 0.000004107 seconds
Frequency       : 15.525 ppm slow
Residual freq   : +0.046 ppm
Skew            : 0.099 ppm
Root delay      : 0.000204 seconds
Root dispersion : 0.000060 seconds
Update interval : 16.0 seconds
Leap status     : Normal

If you are not that sure for your server time. Open a new remote server in the same region. Compare the server date and time, type command:

dateCopy

That’s all.

Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html#configure_ntp