centos/linux自动更新网络时间

安装ntpdate

yum -y install ntpdate

  

查看当前时间

date

  

同步当前时间

ntpdate time.nist.gov; #更新时间
hwclock -w; #将时间写入到硬盘

  

加入定时任务

1.打开crontab
vi /etc/crontab

2.加入定时任务
 * */48 * * * ntpdate time.nist.gov;hwclock -w;

  

猜你喜欢

转载自www.cnblogs.com/achengmu/p/12713377.html