• linux时间不同步问题


    怪问题: 时间同步失效
    系统: centos 6.6  2.6.32-504.el6.x86_64
    情况: 定时任务中写了每分钟同步一次系统时间,定时任务执行成功,时间却未同步,奇怪?
    现象:
    [root@lnmp02 scripts]# crontab -l
    */1 * * * *  ntpdate time.windows.com >/dev/null 2>&1
    ###sunwj#2015/6/19##backup /var/www/html/##
    00 00 * * * /bin/sh /server/scripts/backup.sh  >/dev/null 2>&1
     
    [root@lnmp02 scripts]# /etc/init.d/crond status
    crond (pid  3512) is running...
    [root@lnmp02 scripts]# 
    [root@lnmp02 scripts]# cat /var/log/cron   查看系统日志,显示有进行时间同步
    Jun 20 00:02:01 lnmp02 CROND[3634]: (root) CMD (ntpdate time.windows.com >/dev/null 2>&1)
    Jun 20 00:03:01 lnmp02 CROND[3639]: (root) CMD (ntpdate time.windows.com >/dev/null 2>&1)
    Jun 20 00:04:01 lnmp02 CROND[3645]: (root) CMD (ntpdate time.windows.com >/dev/null 2>&1)
    Jun 20 00:04:27 lnmp02 crontab[3647]: (root) LIST (root)
    Jun 20 00:05:01 lnmp02 CROND[3654]: (root) CMD (ntpdate time.windows.com >/dev/null 2>&1)
    Jun 20 00:05:56 lnmp02 crontab[3658]: (root) LIST (root)
    Jun 20 00:06:02 lnmp02 CROND[3665]: (root) CMD (ntpdate time.windows.com >/dev/null 2>&1)
     
    [root@lnmp02 scripts]# date
    Sat Jun 20 00:06:20 CST 2015
    [root@lnmp02 scripts]# ntpdate time.windows.com >/dev/null 2>&1  把日志中的命令粘贴出来,同步成功!
    [root@lnmp02 scripts]# date
    Sun Jun 21 10:10:03 CST 2015
    [root@lnmp02 scripts]#
     
     
    问题找到了,是因为我命令没有用绝对路径。 下面是更改后的结果,时间同步成功!
    [root@lnmp02 scripts]# crontab -l
    */1 * * * *  /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1 
    ###sunwj#2015/6/19##backup /var/www/html/##
    00 00 * * * /bin/sh /server/scripts/backup.sh  >/dev/null 2>&1
    [root@lnmp02 scripts]# 
  • 相关阅读:
    Java初学—类与对象
    linux dd命令测试U盘读写速度
    路由器的几种访问方式
    制作Linux启动盘并安装Linux系统到实体机
    RAID阵列与LVM逻辑卷组创建
    有关Linux下库的概念、生成和升级和使用等
    LInux中VIM的使用和定制
    如何通过mount命令挂载存储设备
    硬盘分区和系统启动
    RAID阵列与LVM逻辑卷组原理
  • 原文地址:https://www.cnblogs.com/guigujun/p/6196448.html
Copyright © 2020-2023  润新知