タイムゾーンを変更すると、ログファイルやスケジュールされたタスクに影響を与える可能性があるため、変更は慎重に行いましょう。
システムのタイムゾーン情報を表示
$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 25 Mar 6 2023 /etc/localtime -> ../usr/share/zoneinfo/UTC
$ date
Wed Jul 3 06:57:54 UTC 2024
方法1: timedatectl コマンドを使用してタイムゾーンを変更する
$ sudo timedatectl set-timezone <タイムゾーン>
# 日本標準時 (JST) に変更する場合
$ sudo timedatectl set-timezone Asia/Tokyo
方法2: シンボリックリンクを上書きする
# JSTに変更
$ sudo ln -sf /usr/share/zoneinfo/Japan /etc/localtime
# 確認
$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 25 Jul 3 15:59 /etc/localtime -> /usr/share/zoneinfo/Japan
$ date
2024年 7月 3日 水曜日 15:59:14 JST
その他
現在のタイムゾーンやシステムクロックの状態を確認する
$ timedatectl
Local time: Wed 2024-07-03 21:50:21 JST
Universal time: Wed 2024-07-03 12:50:21 UTC
RTC time: Wed 2024-07-03 12:50:22
Time zone: Japan (JST, +0900)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
cronを使っている場合、タイムゾーンを変更後にcronの再起動が必要.
$ sudo service crond restart
参考