0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【備忘録】timedatectl set-timezoneについて

Posted at

背景

久しぶりに新規でEC2インスタンスを作成したのでタイムゾーンを設定しようとした。
タイムゾーンの設定について少し調べたので備忘録として投稿する。

参考ページ

https://linuc.org/study/knowledge/516/
https://siguniang.wordpress.com/2015/03/20/set-timezone/
https://www.t3a.jp/blog/infrastructure/set-timezone/

やったこと

デフォルト状態。上記参考ページから「あれ?このファイルってシンボリックリンクじゃないの?」って思いました。

# ls -l /etc/localtime 
-rw-r--r-- 1 root root 127  3月 16 01:53 /etc/localtime

# cat /etc/localtime
TZif2UTCTZif2?UTC
UTC0

バイナリファイルで全然読めん笑

# ls -l /usr/share/zoneinfo/Asia/Tokyo 
-rw-r--r-- 2 root root 318  2月 11 19:04 /usr/share/zoneinfo/Asia/Tokyo

# cat /usr/share/zoneinfo/Asia/Tokyo 
TZif2	
        ??>p??Y????p??;???ۭ?????݌?????~~LMTJDTJSTTZif2

?????e¤p?????>p??????Y????????p??????;???????????ۭ?????????????݌?????~~LMTJDTJST
JST-9

最初の設定状態

# timedatectl
      Local time: 火 2022-04-05 08:58:35 UTC
  Universal time: 火 2022-04-05 08:58:35 UTC
        RTC time: 火 2022-04-05 08:58:36
       Time zone: n/a (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

あ、rebootしなくても変更反映されてるじゃん

# timedatectl set-timezone Asia/Tokyo

# timedatectl status
      Local time: 火 2022-04-05 20:57:35 JST
  Universal time: 火 2022-04-05 11:57:35 UTC
        RTC time: 火 2022-04-05 11:57:36
       Time zone: Asia/Tokyo (JST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

# date
2022年  4月  5日 火曜日 21:02:34 JST

一応rebootした後にdate打ったら英語表示なんだけどこれは何故でしょう?
また後日調べますか、、、

# reboot

# date
Tue Apr  5 21:08:04 JST 2022

# timedatectl status
      Local time: Tue 2022-04-05 21:32:44 JST
  Universal time: Tue 2022-04-05 12:32:44 UTC
        RTC time: Tue 2022-04-05 12:32:45
       Time zone: Asia/Tokyo (JST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?