linux 系统时间同步校正

发布时间:2019/8/26 16:27:00

安装系统的时候, date时区设置为 shanghai

service ntpd stop     停止ntpd服务

chkconfig ntpd off    停止ntpd服务 开启自动停止  (可用可不用)

# hwclock

# date

# date -s  输入正确的日期和时间

# ntpdate cn.pool.ntp.org

# hwclock --systohc 等同于 hwclock -w  ,将系统时间写入BIOS时间

# clock -w 

把系统时间写入CMOS

小型脚本:

# crontab -e  脚本内容 , (每分钟自动执行1次校时)

*/1 * * * * /usr/sbin/ntpdate cn.pool.ntp.org

*/1 * * * * /sbin/hwclock --systohc

开启脚本自动执行,激活任务计划功能(配置文件)

# service crond start

# chkconfig crond on

* ntpdate -u 跳过防火墙执行同步(部分可能会因为防火墙问题导致同步失败)



Copyright© 2004-2020 河南海腾电子技术有限公司 版权所有   经营性ICP/ISP证 备案号:B1-20180452   豫公网安备 41019702002018号    电子营业执照