In this article, we will delve into the process of troubleshooting time synchronization issues in Ubuntu 18.04. Time synchronization is crucial for many system processes and applications. If your Ubuntu system’s time is not syncing correctly, it can lead to various problems.
- Understanding Time Sync in Ubuntu
- Checking the Status of systemd-timesyncd Service
- Reviewing the Logs
- Verifying the Internet Connection
- Checking the NTP Server Configuration
- Restarting the systemd-timesyncd Service
- Verifying the Synchronization Status
- Additional Solutions
Understanding Time Sync in Ubuntu
Ubuntu uses the
systemd-timesyncd service for time synchronization. This service implements an SNTP (Simple Network Time Protocol) client for synchronizing the system clock across the network. It’s important to ensure that this service is running correctly to maintain accurate system time.
Checking the Status of systemd-timesyncd Service
Firstly, we need to check the status of the
systemd-timesyncd service. This can be done by running the following command in the terminal:
systemctl status systemd-timesyncd
This command will display the current status of the
systemd-timesyncd service. If the service is active but failed, it may provide additional information about the issue.
Reviewing the Logs
The next step in our troubleshooting process is to review the logs of the
systemd-timesyncd service. To do this, we can use the
journalctl command as follows:
journalctl -u systemd-timesyncd
This command will display the logs of the
systemd-timesyncd service. Any error messages in these logs can help identify the specific problem causing the synchronization failure.
Verifying the Internet Connection
Time synchronization requires an active internet connection to reach the NTP servers. Therefore, it’s important to verify that your internet connection is working properly.
Checking the NTP Server Configuration
If the time is still not syncing, the next step is to check if any NTP servers are configured in the
/etc/systemd/timesyncd.conf file. This can be done by opening the file in a text editor with root privileges:
sudo nano /etc/systemd/timesyncd.conf
NTP= line is commented out (starts with a
#) or empty, you can add NTP servers to it. For example:
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
After making the changes, save the file and exit the text editor.
Restarting the systemd-timesyncd Service
To apply the changes, we need to restart the
systemd-timesyncd service. This can be done by running the following command:
sudo systemctl restart systemd-timesyncd
Verifying the Synchronization Status
Finally, we can verify the synchronization status by running the
If the “System clock synchronized” field shows “no”, it means the synchronization is still not successful.
If the above steps do not resolve the issue, there are a couple of additional solutions that you can try.
Solution 1: Set the Correct Permissions
Sometimes, the issue can be caused by incorrect permissions for the
/var/lib/private directory. You can set the correct permissions by running the following command:
sudo chmod 0700 /var/lib/private
Then restart the
systemd-timesyncd service and check the synchronization status again.
Solution 2: Remove the systemd Directory
If the issue persists, you can try removing the
/var/lib/private/systemd directory by running:
sudo rm -r /var/lib/private/systemd
This solution should be used as a last resort and may or may not be necessary depending on your specific situation.
In this article, we’ve covered a systematic approach to troubleshooting time sync issues in Ubuntu 18.04. If none of the above solutions work, it may be helpful to consult the official documentation for
systemd-timesyncd and review any relevant forum threads or articles specific to your Linux distribution. Remember, maintaining accurate system time is crucial for many applications and processes, so it’s important to resolve any time sync issues promptly.
To check the status of the systemd-timesyncd service, run the command
systemctl status systemd-timesyncd in the terminal.
To review the logs of the systemd-timesyncd service, use the command
journalctl -u systemd-timesyncd.
If the systemd-timesyncd service is active but failed, you can check the logs using the
journalctl command to get more information about the issue.
You can verify your internet connection by checking if you can access websites or use other network-dependent services. A working internet connection is necessary for time synchronization.
To check the NTP server configuration, open the
/etc/systemd/timesyncd.conf file in a text editor with root privileges (e.g.,
sudo nano /etc/systemd/timesyncd.conf). Look for the
NTP= line. If it is commented out or empty, you can add NTP servers to it.
To restart the systemd-timesyncd service, run the command
sudo systemctl restart systemd-timesyncd in the terminal.
To verify the synchronization status, use the command
timedatectl status in the terminal. If the "System clock synchronized" field shows "no", the synchronization is not successful.
If the above steps do not resolve the issue, you can try setting the correct permissions for the
/var/lib/private directory or removing the
/var/lib/private/systemd directory as mentioned in the additional solutions. However, these solutions should be used with caution and as a last resort.