Linux

Set Linux Server date and time using NTP

NTP will keep your server’s time in sync with other servers in your chosen time zone. As standard, all our dedicated servers use the system default timezone shipped with the installed OS package. On virtual servers, the time is set to UK time but you can change these to any time zone you like. Follow the guide below to set the date and time of your Linux server. Remember to replace the UK pool with your chosen pool. A list of NTP Pools can be found here. If you use cPanel you can use WHM to set the time on your server. Just log in and in the search bar type “time.

However, it’s important to note that if you run an OpenVZ or Virtuozzo server then the time is set on the host node and you cannot use this guide to change the date and time on these types of servers. To get started setting the time on your server just log in using SSH as the root user and run the commands one by one below. You can repeat the process to modify the timezone.

Install NTP On CentOS/RockyLinux/AlmaLinux

#CentOS 7

yum install ntp -y

#AlmaLinux 8, RockyLinux 8

dnf install ntp -y

Install NTP On Ubuntu/Debian

apt install ntp

Next, we want to turn on NTP in the server;

/sbin/chkconfig ntpd on

Next, let’s start NTP;

/etc/init.d/ntpd start

Set Date & Time NTP

So now it’s time to choose an NTP pool. There is a list of NTP servers here. Choose the required NTP pool then issue the ntpdate command in the comes. This will set the date and time of the NTP server in your Linux server;

ntpdate uk.pool.ntp.org

Finally, check the Date and Time on the server;

root@server [/] date
Thu Nov 27 12:58:20 GMT 2014

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button