WUYUANS
Just for Sharing

debian系统时间设置

2012年10月23日 分类:DebianLinux

前段时间把Debian升级到了sid,系统时间总是快8个小时。debian这边设好了,到了windows就会慢8个小时。网上说只要修改/etc/default/rcS中的UTC=no就行了,但还是没反映,没办法,一步步找问题。发现在/etc/rcS.d/S05hwclock.sh有这样一段话:

# 2012-02-16 Roger Leigh [email protected]
# - Use the UTC/LOCAL setting in /etc/adjtime rather than
# the UTC setting in /etc/default/rcS. Additionally
# source /etc/default/hwclock to permit configuration.

也就是说时间是按照/etc/adjtime设置的,而不是/etc/default/rcS,晕倒。查了下adjtime文件,原来这个才是现在调整时间的设置文件,那个rcS已经被忽略了,也就是网上的那些方法只适合以前的系统,看来走了不少弯路啊。
adjtime文件不需要手动修改,使用hwclock命令就行了:

hwclock -w --localtime

这时adjtime第三行会变成LOCAL,然后再用正确的时间修改系统时间:

date -s 13:20:00

或者用ntpdate网上同步一下,这里就不说了。然后把时间写入主板中:(如果硬件时间是正确的话可以省略)

hwclock --systohc

这样debian的系统时间和windows的就一样了。

作者:wuyuan 本文来自Wuyuan's Blog 转载请注明,谢谢! 文章地址: https://www.wuyuans.com/blog/detail/105