如果虚拟机(linux)可以通外网,用方法一,否则用方法二;
======= 方法一 ==========
echo "59 * * * * /usr/sbin/ntpdate time.windows.com" >> tmp.cron; crontab tmp.cron; rm -f tmp.cron
======= 方法二 ==========
1.在准备做时间服务器的linux计算机上执行如下命令
cp /etc/ntp.conf /etc/ntp.conf.back
echo "server 127.127.1.0" > /etc/ntp.conf
echo "fudge 127.127.1.0 stratum 8" >> /etc/ntp.conf
echo "server 0.rhel.pool.ntp.org" >> /etc/ntp.conf
echo "server 1.rhel.pool.ntp.org" >> /etc/ntp.conf
echo "server 2.rhel.pool.ntp.org" >> /etc/ntp.conf
echo "driftfile /var/lib/ntp/drift" >> /etc/ntp.conf
chkconfig ntpd on
service ntpd restart
2.在虚拟机上执行
echo "59 * * * * /usr/sbin/ntpdate 刚才内网时间服务器IP" >> tmp.cron; crontab tmp.cron; rm -f tmp.cron