部分软件需要时间同步才能正常运行,然而有些机器就是时间走的不正常。
解决方法:
yum -y install ntp #安装ntp工具
rm -rf /etc/localtime #设置时区
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
/usr/sbin/ntpdate -u cn.pool.ntp.org #校准时间
hwclock -w #写入时间
查看当前时间:
hwclock -r
date
设置自动时间同步:
/etc/rc.d/rc.local 添加:
/usr/sbin/ntpdate -u cn.pool.ntp.org> /dev/null 2>&1; /sbin/hwclock -w
crontab -e 添加:
00 10 * * * /usr/sbin/ntpdate -u cn.pool.ntp.org > /dev/null 2>&1; /sbin/hwclock -w