Let me introduce the relevant tutorials
The following commands need to be executed with root permission, or you will be prompted for insufficient permissions
First determine if the server has ntpdate this software:
Which ntpdate if not found, you will need to install a ntpdate.
Use this command under Redhat, CentOS:
The code is as follows |
Copy Code |
Yum Install-y NTP |
Use this command under Debian and Ubuntu:
The code is as follows |
Copy Code |
Apt-get install-y Ntpdate |
After installation, execute the following command to obtain accurate time via the service server
Ntpdate-u pool.ntp.orgpool.ntp.org
is a set of timing server virtual cluster, in the world has more than 3,000 servers, only need to write on the line, specifically which server to provide services without concern.
If there is a similar error following the execution of the command, the VPS does not allow the VPS to set its own time:
9 05:13:57 ntpdate[7299]: Step-systime:operation not permitted
After the computer runs for some time, the time is likely to produce some deviations, so it also requires regular synchronization time, then use the crontab to carry out the command on a regular basis, such as: 1 o'clock in the morning every day to perform
The command for synchronization time is: ' Ntpdate timeserver ' here the timeserver for the time server IP or hostname, commonly used timeserver have 210.72.145.44, time.windows.com ( Windows Time server). If you want to sync every 6 hours, specify a scheduled task.
*/6 * * * */usr/sbin/ntpdate 210.72.145.44 >/dev/null