centos内网校时


centos内网校时
 
选中某台机器 ,如果机器不能连接外网:
1、先对此机器设置正确的时区和时间
 
时区:
 
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
或者
 
ln -sf  /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
时间,设置
 
date 010318242008(月日时分年)(完整书写)
 
2、设置硬件时间,使其于上面设置的系统时间通步
 
hwclock --systohc
 
  如果机器能连接外网 :
 
    1、
 
      cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
     或者
 
      ln -sf  /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
    ntpdate pool.ntp.org
 
   2、hwclock --systohc
 
然后,在此台机器上开启ntp server
 
安装服务:yum -y install ntp
 
开机启动:chkconfig ntpd on
 
启动服务:service ntpd start
 
在内网中其他不能连接外网的机器,就可以此ntp server上面的时间来较准了。
 
定时较准时间:
 
# crontab -e       
//打开linux定时计划任务
0 23 * * * /usr/sbin/ntpdate 210.72.145.44  
//时间格式如下:如果23改为0-23/2 就表示每隔2小时执行一次
* * * * * *
| | | | | | 
| | | | | +-- Year              (range: 1900-3000)
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute (range: 0-59) //加入这一行信息 ,ip可指定为上面已配置好ntp server的机器IP。 以上命令设置好后存盘。 
# /sbin/service crond reload //重载linux计划任务
 

相关内容

    暂无相关文章