Linux Server Install: Part 10
Tick-Tock — Check out that NTP Time Server, bruh.
Previous
Install NTP
sudo apt install -y ntp
To check the configuration of the NTP daemon in Linux, you can use the ntpq
command. This command allows you to query the NTP server and view its current settings and status.
This will display a list of the NTP servers that are currently being used by the NTP daemon, along with their status and other information. You can also use the -c
flag to specify a specific command to run against the NTP server. For example, you could use the following command to view the current status of the server:
ntpq -p -c rv
You can also view the configuration file for the NTP daemon, which is typically located at /etc/ntp.conf
. This file contains the settings for the NTP server, including the address of the server and other options. You can use a text editor to view and edit the file, but be careful not to make any changes that could cause the NTP daemon to stop functioning correctly.
systemctl status systemd-timesyncd
is a command that you can use to view the status of the systemd-timesyncd
service in Linux. systemd-timesyncd
is a service that is responsible for synchronizing the system clock with a remote time server using the Network Time Protocol (NTP).
The systemctl
command is used to control and manage system services in Linux. The status
subcommand allows you to view the current status of a service, including whether it is running or stopped, and any recent error messages or warnings.
When you run the systemctl status systemd-timesyncd
command, you will see output similar to the following:
This output shows that the systemd-timesyncd
service is currently running and that it has successfully synchronized the system clock with the time server specified in its configuration file. You can use this information to troubleshoot any issues with the time synchronization on your system.
Status
is configured for ntp.ubuntu.com
, which is an external source, so we’ll need to edit the NTP server in timesyncd.conf
.
To edit the /etc/systemd/timesyncd.conf
file in an Ubuntu server and set it to use an internal NTP server, you can follow these steps:
sudo nano /etc/systemd/timesyncd.conf
- Scroll down to the
[Time]
section of the file and find theNTP
option. This option specifies the address of the NTP server that thesystemd-timesyncd
service will use to synchronize the system clock. - Replace the existing NTP server address with the address of your internal NTP server. For example, if your internal NTP server has an IP address of
192.168.1.10
, you would set theNTP
option to the following:
NTP=192.168.1.10
3. Save your changes to the file by pressing CTRL + O
and then CTRL + X
to exit the nano
editor.
4. Stop the service
sudo timedatectl set-ntp off
5. Start the service
sudo timedatectl set-ntp on
6. Now check the server and status.
systemctl status systemd-timesyncd
7. Or restart the systemd-timesyncd
service to apply the changes you made to the configuration file:
systemctl restart systemd-timesyncd
After you have followed these steps, the systemd-timesyncd
service will use your internal NTP server to synchronize the system clock. You can use the systemctl status systemd-timesyncd
command to view the current status of the service and confirm that it is using the correct NTP server.