yum -y install ntpdate

  

查看当前时间

date

  

同步当前时间

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

  

加入定时任务

注意一定要带:root ,否则不执行

1.打开crontab
vi /etc/crontab

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

  

 如果ntpdate time.nist.gov;hwclock -w; 不执行,将他写到.sh文件中

例如:

/etc/rc.d/sys_uptime.sh

#!/bin/bash
ntpdate time.nist.gov;
hwclock -w;

  

重新编辑/etc/crontab

1.打开crontab
vi /etc/crontab

2.加入定时任务
 * */48 * * * root /etc/rc.d/sys_uptime.sh

  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-09-27
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2021-07-31
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
相关资源
相似解决方案