没开utc,CMOS时间比系统时间慢8个小时

重复贴和参考价值不大的帖子,版主维护
回复
neocorleone
帖子: 196
注册时间: 2007-06-06 14:24
送出感谢: 0
接收感谢: 0

没开utc,CMOS时间比系统时间慢8个小时

#1

帖子 neocorleone » 2007-10-26 9:17

在ubuntu下,时间是准确的本地时间,虽然没开UTC,但是开机前进CMOS看,比本地时间慢了8个小时,如果是进windows的话,时间也就是慢8个小时的。
另外,进ubuntu的话,用hwclock --show看的话,也是准确的本地时间。这是为什么啊?
/etc/init.d/hwclock.sh这个文件的内容是

代码: 全选

#!/bin/sh
# hwclock.sh	Set and adjust the CMOS clock, according to the UTC
#		setting in /etc/default/rcS (see also rcS(5)).
#
# Version:	@(#)hwclock.sh  2.00  14-Dec-1998  miquels@cistron.nl
#
# Patches:
#		2000-01-30 Henrique M. Holschuh <hmh@rcm.org.br>
#		 - Minor cosmetic changes in an attempt to help new
#		   users notice something IS changing their clocks
#		   during startup/shutdown.
#		 - Added comments to alert users of hwclock issues
#		   and discourage tampering without proper doc reading.

# WARNING:	Please read /usr/share/doc/util-linux/README.Debian.hwclock
#		or /usr/share/doc/util-linux/README.Debian.hwclock
#		before changing this file. You risk serious clock
#		misbehaviour otherwise.

### BEGIN INIT INFO
# Provides:          hwclock
# Required-Start:    mountdevsubfs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
### END INIT INFO

FIRST=no	# debian/rules sets this to 'yes' when creating hwclockfirst.sh

# Set this to any options you might need to give to hwclock, such
# as machine hardware clock type for Alphas.
HWCLOCKPARS="--directisa“

hwclocksh()
{
    [ ! -x /sbin/hwclock ] && return 0
    . /etc/default/rcS

    . /lib/lsb/init-functions
    verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; }

    [ "$GMT" = "-u" ] && UTC="yes"
    case "$UTC" in
       no|"")	GMT="--localtime"
		UTC=""
		if [ "X$FIRST" = "Xyes" ] && [ ! -r /etc/localtime ]; then
		    if [ -z "$TZ" ]; then
			log_action_msg "System clock was not updated at this time"
			return 1
		    fi
		fi
		;;
       yes)	GMT="--utc"
		UTC="--utc"
		;;
       *)	log_action_msg "Unknown UTC setting: \"$UTC\""; return 1 ;;
    esac

    case "$BADYEAR" in
       no|"")	BADYEAR="" ;;
       yes)	BADYEAR="--badyear" ;;
       *)	log_action_msg "unknown BADYEAR setting: \"$BADYEAR\""; return 1 ;;
    esac

    case "$1" in
	start)
	    if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then
		echo "0.0 0 0.0" > /etc/adjtime
	    fi

	    if [ ! -w /etc/adjtime ]; then
		NOADJ="--noadjfile"
	    else
	    	NOADJ=""
	    fi

	    if [ "$FIRST" != yes ]; then
		# Uncomment the hwclock --adjust line below if you want
		# hwclock to try to correct systematic drift errors in the
		# Hardware Clock.
		#
		# WARNING: If you uncomment this option, you must either make
		# sure *nothing* changes the Hardware Clock other than
		# hwclock --systohc, or you must delete /etc/adjtime
		# every time someone else modifies the Hardware Clock.
		#
		# Common "vilains" are: ntp, MS Windows, the BIOS Setup
		# program.
		#
		# WARNING: You must remember to invalidate (delete)
		# /etc/adjtime if you ever need to set the system clock
		# to a very different value and hwclock --adjust is being
		# used.
		#
		# Please read /usr/share/doc/util-linux/README.Debian.hwclock
		# before enablig hwclock --adjust.

		#hwclock --adjust $GMT $BADYEAR
		:
	    fi

	    if [ "$HWCLOCKACCESS" != no ]; then
		log_action_msg "Setting the system clock"

		# Copies Hardware Clock time to System Clock using the correct
		# timezone for hardware clocks in local time, and sets kernel
		# timezone. DO NOT REMOVE.
		if /sbin/hwclock --hctosys $GMT $HWCLOCKPARS $BADYEAR $NOADJ; then
		    #	Announce the local time.
		    verbose_log_action_msg "System Clock set to: `date $UTC`"
		else
		    log_warning_msg "Unable to set System Clock to: `date $UTC`"
		fi
	    else
		verbose_log_action_msg "Not setting System Clock"
	    fi
	    ;;
	stop|restart|reload|force-reload)
	    #
	    # Updates the Hardware Clock with the System Clock time.
	    # This will *override* any changes made to the Hardware Clock.
	    #
	    # WARNING: If you disable this, any changes to the system
	    #          clock will not be carried across reboots.
	    #
	    if [ "$HWCLOCKACCESS" != no ]; then
		log_action_msg "Saving the system clock"
		if [ "$GMT" = "-u" ]; then
		    GMT="--utc"
		fi
		if /sbin/hwclock --systohc $GMT $HWCLOCKPARS $BADYEAR; then
		    verbose_log_action_msg "Hardware Clock updated to `date`"
		fi
	    else
		verbose_log_action_msg "Not saving System Clock"
	    fi
	    ;;
	show)
	    if [ "$HWCLOCKACCESS" != no ]; then
		/sbin/hwclock --show $GMT $HWCLOCKPARS $BADYEAR
	    fi
	    ;;
	*)
	    log_success_msg "Usage: hwclock.sh {start|stop|reload|force-reload|show}"
	    log_success_msg "       start sets kernel (system) clock from hardware (RTC) clock"
	    log_success_msg "       stop and reload set hardware (RTC) clock from kernel (system) clock"
	    return 1
	    ;;
    esac
}

hwclocksh "$@"

/etc/default/rcS里的内容是

代码: 全选

#
# /etc/default/rcS
#
# Default settings for the scripts in /etc/rcS.d/
#
# For information about these variables see the rcS(5) manual page.
#
# This file belongs to the "initscripts" package.

TMPTIME=0
SULOGIN=no
DELAYLOGIN=no
UTC=no
VERBOSE=no
FSCKFIX=n
时区选的是上海。
头像
iblicf
帖子: 3766
注册时间: 2007-01-15 17:15
送出感谢: 0
接收感谢: 0

#2

帖子 iblicf » 2007-10-26 9:22

这个似乎是你 win 下边的时间设置不对 ...

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\中添加一项数据类型为REG_DWORD,名称为RealTimeIsUniversal,值设为1

不太确定,仅供参考
上次由 iblicf 在 2007-10-26 9:24,总共编辑 1 次。
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

#3

帖子 eexpress » 2007-10-26 9:24

使用UTC的系统。就是这样的。bios就是UTC。 hwclock的,自己看参数。就明白了。
● 鸣学
neocorleone
帖子: 196
注册时间: 2007-06-06 14:24
送出感谢: 0
接收感谢: 0

#4

帖子 neocorleone » 2007-10-26 9:26

iblicf 写了:这个似乎是你 win 下边的时间设置不对 ...

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\中添加一项数据类型为REG_DWORD,名称为RealTimeIsUniversal,值设为1。
这是让windows开UTC的意思吧
我在ubuntu并没有开UTC啊,结果就是CMOS里的时间慢
把windows的UTC打开的确可以解决问题,但是,我想知道,为什么ubuntu下utc没打开,ubuntu系统时间还是比CMOS快8个小时,并且hwclock --show显示的是本地时间(系统时间)。
neocorleone
帖子: 196
注册时间: 2007-06-06 14:24
送出感谢: 0
接收感谢: 0

#5

帖子 neocorleone » 2007-10-26 9:28

eexpress 写了:使用UTC的系统。就是这样的。bios就是UTC。 hwclock的,自己看参数。就明白了。
怎么把BIOS的改成本地时间
我试过 hwclock --localtime --systohc
没用处
回复

回到 “归档贴”