ubuntu下的时间设定(硬件时间,系统时间,本地时间)
2015-04-02 12:36
197 查看
问题的来由是在这里:
在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)
在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)
相关文章推荐
- ubuntu修改时间、显示硬件时间、同步系统时钟(date命令使用方法)
- Ubuntu修改系统时间及与硬件时间同步
- ubuntu 系统时间和硬件时间的几点认识
- ubuntu 系统时间和硬件时间的几点认识
- Ubuntu 16.04将系统时间写入到硬件时间BIOS
- ubuntu更改硬件时间【win10双系统】
- 【Ubuntu】Windows与Linux(Ubuntu)双系统时间不一致 (相差8小时) 的解决方法
- linux 设置系统时间和硬件时间
- 如何设置gec2410开发板系统时间及硬件时间(RTC)
- 把Ubuntu的时钟调整为本地时间
- 关于jdk中API取出的日期和本地系统时间不一致的解决
- C#利用Win32 API函数设定系统时间
- 用C#设置系统时间和本地时间
- Java中获取本地系统时间的方法
- XP于Ubuntu双系统时开机默认启动顺序到设定
- 双系统,Ubuntu时间不对,相差8个小时
- 自己写的jquery组件,本地显示系统时间,可以随时更改时间
- LInux系统时间和硬件时间
- c# 修改系统本地时间
- linux windows 硬件时间,系统时间,时区处理全过程,实践出真知 ^_^