部分软件需要时间同步才能正常运行,然而有些机器就是时间走的不正常。
解决方法:
1 |
yum -y install ntp #安装ntp工具 |
1 2 |
rm -rf /etc/localtime #设置时区 ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
1 |
/usr/sbin/ntpdate -u cn.pool.ntp.org #校准时间 |
1 |
hwclock -w #写入时间 |
查看当前时间:
1 |
hwclock -r |
1 |
date |
设置自动时间同步:
/etc/rc.d/rc.local 添加:
1 |
/usr/sbin/ntpdate -u cn.pool.ntp.org> /dev/null 2>&1; /sbin/hwclock -w |
crontab -e 添加:
1 |
00 10 * * * /usr/sbin/ntpdate -u cn.pool.ntp.org > /dev/null 2>&1; /sbin/hwclock -w |
原创文章,作者:discovery,如若转载,请注明出处:https://www.pingzz.com/jiaocheng/xitong/352.html