IT関連

Amazon Lightsail WordPress Certified by Bitnami システム時間調整

timedatectlコマンドを実行すると現在の設定はわかります。

$ timedatectl
                      Local time: 金 2019-11-15 01:28:34 JST
                  Universal time: 木 2019-11-14 16:28:34 UTC
                        RTC time: 木 2019-11-14 16:28:34
                       Time zone: Asia/Tokyo (JST, +0900)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

日本時間を設定します。

$ timedatectl set-timezone Asia/Tokyo

念の為、設定が変わった事を確認します。

$ timedatectl
                      Local time: 金 2019-11-15 01:35:59 JST
                  Universal time: 木 2019-11-14 16:35:59 UTC
                        RTC time: 木 2019-11-14 16:35:59
                       Time zone: Asia/Tokyo (JST, +0900)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

RTCに同期する時刻をLocal Timeにする

$ timedatectl set-local-rtc true
                      Local time: 金 2019-11-15 01:38:59 JST
                  Universal time: 木 2019-11-14 16:38:59 UTC
                        RTC time: 金 2019-11-15 01:38:59
                       Time zone: Asia/Tokyo (JST, +0900)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode can not 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'.

最後は以下のコマンドでハードウェアにも設定して、再起動してもリセットしないようにします。

hwclock --systohc

追記:cronがUTCで実行されてしまう・・・ の対策

上記の対応した翌日、実行したタスクを確認したら、またUTC時間のままで実行しています。日本時間になっていません。
急遽調べたところ、Cronにも反映するのに、Crondを再起動する必要がります。

debianの場合、以下のコマンドになります。

sudo systemctl restart cron

ちなみに、cronの起動

sudo systemctl start cron

cronの停止

sudo systemctl stop cron

cronの状態確認

コメント

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