zoukankan      html  css  js  c++  java
  • ubuntu下的时间设定(硬件时间,系统时间,本地时间)

    问题的来由是在这里:

    在cron里设定任务是在凌晨6点执行,检查日志时发现时间总是不对,是在22点左右的时间执行的。研究发现,任务是在本地时间的6点执行了,但不知为什么syslog中的时间都是为utc时间。

    这里涉及到硬件时间,系统时间,本地时间几个概念,下面是涉及到一些命令操作:

    设置时区的基本方法:

    http://blog.sina.com.cn/s/blog_6c9d65a1010145st.html

    1. sudo tzselect

    二、复制文件到/etc目录下
    sudo cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
     
    三、更新时间
    sudo ntpdate time.windows.com
     
    检查时间:

    pwsync@wepingwest:/etc/default$ date

    Thu Apr  2 12:26:33 CST 2015

    pwsync@wepingwest:/etc/default$ date -u

    Thu Apr  2 04:26:55 UTC 2015

    pwsync@wepingwest:/etc/default$ date -R

    Thu, 02 Apr 2015 12:27:16 +0800

    硬件时间:

    pwsync@wepingwest:/etc/default$ sudo hwclock --show

    Thu 02 Apr 2015 12:27:42 PM CST  -0.317712 seconds

    这里保证硬件时间也为localtime.

    最后为了在syslog等日志中也显示本地时间,需要在/etc/default/rcS将utc设置成no.(需要重启系统)

     

    为了将系统的时间保存在硬件上,需要

    # hwclock --systohc

    (http://blog.chinaunix.net/uid-26495963-id-3048079.html)

    (http://www.111cn.net/sys/linux/58514.htm)

     

  • 相关阅读:
    IAR EWARM PRINTF/SCANF FORMATTER
    Windows Self Signed Driver
    Remove a Driver Package from the Driver Store
    CMSIS-DAP调试器
    CHM文件无法查看内容解决办法
    HRESULT 0x80131515 解决方法
    dmalloc 原文 翻译整理
    Linux错误代码
    Windows 错误代码
    调码王版本历史
  • 原文地址:https://www.cnblogs.com/hurner/p/4386576.html
Copyright © 2011-2022 走看看