Setting up time synchronization on servers is important, as it is used by applications such as:
- Two-factor authentication
- Database
- File system
We will look at options for setting up and synchronizing time for different services.
1. Setting the time for VPS servers
On VPS servers, time is synchronized with the main physical server in the UTC/GMT (0) time zone and there is no need to configure its synchronization. Although most servers operate in the UTC/GMT (0) time zone, you can also change the time zone to your own.
1.1 Viewing the current time zone
timedatectl
1.2 View a list of available time zones
timedatectl list-timezones
1.3 Setting the time zone
timedatectl set-timezone Europe/Moscow
1.3.1 Alternative way to set the time zone
ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime
To check the changes, use the command from paragraph 1.1
2. Setting the time for VDS servers
2.1 Setting the time zone
Setting the time zone is similar in description to that for a VPS server, there are no differences in the settings, use the description above.
2.2 Setting up time synchronization
2.2.1 Installing the synchronization service
apt install ntpdate ntp
2.2.2 One-time time synchronization
/usr/sbin/ntpdate 1.ru.pool.ntp.org
2.2.3 Constant synchronization
2.2.3.1 Let's check the configuration file
/etc/ntp.conf
server 0.ru.pool.ntp.org iburst
server 1.ru.pool.ntp.org iburst
server 2.ru.pool.ntp.org iburst
server 3.ru.pool.ntp.org iburst
2.2.3.2 Disable systemd service time synchronization
timedatectl set-ntp no
2.2.3.3 Set up the service
/etc/init.d/ntp restart
systemctl enable ntp
2.2.3.4 Checking synchronization status
ntpq -p
Now the time on the server is synchronized by the NTP service.
No Comments Yet