在安裝Linux操作系統時,有一個選項是UTC,默認是勾上的。系統安裝好后會把BIOS時間當成UTC標准時間,然后再根據時區調整系統時間。所以會發生明明時區設置正確,時間卻不正確的情況。所以安裝時,最好是取消那個勾。
如果已經裝好,可以通過修改配置文件的方式修改。
redhat系統 修改/etc/adjtime第三行為LOCAL
[root@db-01 ~]# vim /etc/adjtime
-0.098726 1524046105 0.000000
1524046105
LOCAL
~
The format of the adjtime file is, in ASCII:
Line 1: 3 numbers, separated by blanks: 1) systematic drift rate in seconds per day, floating
point decimal; 2) Resulting number of seconds since 1969 UTC of most recent adjustment or cali-
bration, decimal integer; 3) zero (for compatibility with clock(8)) as a decimal integer.
Line 2: 1 number: Resulting number of seconds since 1969 UTC of most recent calibration. Zero
if there has been no calibration yet or it is known that any previous calibration is moot (for
example, because the Hardware Clock has been found, since that calibration, not to contain a
valid time). This is a decimal integer.
Line 3: "UTC" or "LOCAL". Tells whether the Hardware Clock is set to Coordinated Universal
Time or local time. You can always override this value with options on the hwclock command
line.
You can use an adjtime file that was previously used with the clock(8) program with hwclock.
修改時區的方法
修改配置文件/etc/sysconfig/clock
更新時區tzdata-update
ubuntu系統
hwclock的時區在/etc/default/rcS文件中設置,里面有一個參數UTC,默認值為True,表示使用UTC時 區,如果設置為no,那表示使用osclock的時區