PR

Windows/Linuxとデュアルブートで時計が9時間ずれるのを直すコマンド

アイキャッチ9時間ずれ Linuxをつかおう!!
記事内に広告が含まれています。

よく使うので、まとめておきました。

スポンサーリンク

hwclock コマンド

対応ディストリビューション:Linux Mint、MX Linuxなど

Windows/Linuxでズレをなくす

管理者権限で実行する必要があるので、先頭に"sudo"をつけます。

コマンド

sudo hwclock -v -w -l

実行結果

$sudo hwclock -v -w -l

hwclock from util-linux 2.38.1
System Time: 1726293071.864511
開こうとしています: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1726293055 seconds after 1969
Last calibration done at 1726293055 seconds after 1969
ハードウェアの時刻は UTC です
ハードウェアの時刻が ローカル時刻 に設定されているものと仮定します。
RTC タイプ: 'rtc_cmos'
Using delay: 0.500000 seconds
missed it - 1726293071.866771 is too far past 1726293071.500000 (0.366771 > 0.001000)
1726293072.500000 is close enough to 1726293072.500000 (0.000000 < 0.002000)
Set RTC to 1726293072 (1726293071 + 1; refsystime = 1726293071.000000)
Setting Hardware Clock to 14:51:12 = 1726293072 seconds since 1969
ioctl(RTC_SET_TIME) に成功しました。
Not adjusting drift factor because the --update-drift option was not used.
New /etc/adjtime data:
0.000000 1726293071 0.000000
1726293071
LOCAL

元に戻す

コマンド

sudo hwclock -v -w -u

実行結果

$ sudo hwclock -v -w -u

hwclock from util-linux 2.38.1
System Time: 1726293055.838070
開こうとしています: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1726138525 seconds after 1969
Last calibration done at 1726138525 seconds after 1969
ハードウェアの時刻は ローカル時刻 です
ハードウェアの時刻が UTC に設定されているものと仮定します。
RTC タイプ: 'rtc_cmos'
Using delay: 0.500000 seconds
missed it - 1726293055.839617 is too far past 1726293055.500000 (0.339617 > 0.001000)
1726293056.500000 is close enough to 1726293056.500000 (0.000000 < 0.002000)
Set RTC to 1726293056 (1726293055 + 1; refsystime = 1726293055.000000)
Setting Hardware Clock to 05:50:56 = 1726293056 seconds since 1969
ioctl(RTC_SET_TIME) に成功しました。
Not adjusting drift factor because the --update-drift option was not used.
New /etc/adjtime data:
0.000000 1726293055 0.000000
1726293055
UTC

スポンサーリンク

timedatectl コマンド

対応ディストリビューション:Ubuntuなど

Windows/Linuxでズレをなくす

コマンド

timedatectl set-local-rtc 1
 もしくは
timedatectl set-local-rtc true

実行結果(timedatectlコマンドで調べる)

$ timedatectl set-local-rtc 1

$ timedatectl
Local time: 土 2024-09-14 13:47:45 JST
Universal time: 土 2024-09-14 04:47:45 UTC
RTC time: 土 2024-09-14 13:47:45
Time zone: Asia/Tokyo (JST, +0900)

System clock synchronized: yes
NTP service: active
RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
This mode cannot be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.

元に戻す

コマンド

timedatectl set-local-rtc 0
 もしくは
timedatectl set-local-rtc false

実行結果(timedatectlコマンドで調べる)

$ timedatectl set-local-rtc 0

$ timedatectl
Local time: 土 2024-09-14 13:55:03 JST
Universal time: 土 2024-09-14 04:55:03 UTC
RTC time: 土 2024-09-14 04:55:03
Time zone: Asia/Tokyo (JST, +0900)

コメント

タイトルとURLをコピーしました