4、CentOS下同步时间

vi /etc/crontab 添加下面这行

30 21 * * * root /usr/sbin/ntpdate cn.pool.ntp.org && /sbin/hwclock -w

30 21 * * * root /usr/sbin/ntpdate 210.72.145.44 && /sbin/hwclock -w

:wq (保存退出)
手动更新时间方法:ntpdate cn.pool.ntp.org
hwclock -w 这里是更新ROM的时间

文件格式为:分钟(0-59) 小时(0-23) 日期(1-31) 月份(1-12) 周(0-7)

user command
意思是:root用户 在每天21:30 分执行ntpdate comamnd 同步到 cn.pool.ntp.org 这个时间池,并且将更新的时间写入到 ROM里保存。

备注:不要忘记开启服务啊!
chkconfig ntpd --list (查看0~6个runlevel 是否按照阁下意愿开启或关闭 ntpd服务)
chkconfig ntpd --level 35 on (开启runlevel 3和5的ntpd服务)
chkconfig ntpd on (开启runlevel 2345的ntpd服务)
chkconfig ntpd off (关闭所有runlevel的ntpd服务)

bash: chkconfig: command not found解决办法

[root@xuniji ~]# chkconfig
bash: chkconfig
: command not found
[root@xuniji ~]# rpm -aq |grep chkconfig
chkconfig
-1.3.30.1-2
[root@xuniji ~]# export PATH=/sbin:$PATH
[root@xuniji ~]# chkconfig
chkconfig
version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage:   chkconfig --list [name]
         chkconfig --add <name>
         chkconfig --del <name>
         chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities>

[root@xuniji ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/gtl/bin
[root@xuniji ~]# PATH="$PATH":/sbin
[root@xuniji ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/gtl/bin:/sbin

大功告成!!!



国内常用NTP服务器地址及IP

http://blog.csdn.net/pengyouchuan/article/details/8084701
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值