LoginSignup
0
0

More than 1 year has passed since last update.

WebArena Indigo 環境設定4)時間設定の変更

Last updated at Posted at 2021-12-18

WebArena Indigo 環境設定3)他のサーバとのssh接続
https://qiita.com/naga_kt/items/eadb6cb39f7f2fc2216d
の続き。

 デフォルト設定のままではUTC時間である。

$date
Wed Dec 15 23:42:06 UTC 2021

 不便なのでJSTに変えておく。
 ここでUTC時間なのはdateだけでなくて、cronもUTC時間で動いている。同時に変える必要がある。

タイムゾーンの変更(CentOS7/RockyLinux8)

 時間設定の変更は以下のようにして行なう。/etc/localtimeのリンク先を変えることで、タイムゾーンを変更すればいい。

$su
Password:
#cd /etc/
#ls -lrt localtime
lrwxrwxrwx. 1 root root 25 Oct  5  2018 localtime -> ../usr/share/zoneinfo/UTC
#ln -sf  /usr/share/zoneinfo/Asia/Tokyo localtime
#ls -lrt localtime
lrwxrwxrwx. 1 root root 30 Dec 16 08:54 localtime -> /usr/share/zoneinfo/Asia/Tokyo
#date
Thu Dec 16 08:54:29 JST 2021

タイムゾーンの変更(Ubuntu20.04LTS)

 Ubuntuでは以下のように行う。

$su
Password:
#cd /etc/
#ls -lrt localtime
lrwxrwxrwx 1 root root 27 Apr  9 06:07 localtime -> /usr/share/zoneinfo/Etc/UTC
# timedatectl set-timezone Asia/Tokyo
#ls -lrt localtime
lrwxrwxrwx 1 root root 30 Apr 12 11:33 localtime -> /usr/share/zoneinfo/Asia/Tokyo
#date
Tue Apr 12 11:33:54 JST 2022

cronの時間設定の変更(CentOS7/RockyLinux8)

 以下も行なってcornの時間設定も変更する。

#service crond restart
Redirecting to /bin/systemctl restart crond.service
#service rsyslog restart
Redirecting to /bin/systemctl restart rsyslog.service

 cronのログは/var/log/cronに吐き出されているが、crondだけでなく、rsyslogも再起動することで、ログにJSTで吐き出されるのを確認することができる。

cronの時間設定の変更(Ubuntu20.04LTS)

 Ubuntuでは以下のように行う。

# systemctl restart cron.service
# systemctl restart rsyslog.service

WebArena Indigo 環境設定5)プロセス最大値の変更
https://qiita.com/naga_kt/items/49d04303c26d2a612529
に続く。


参考記事

CentOS
Amazon Linuxでタイムゾーンを変更してcronの実行時刻にも反映させる
https://qiita.com/owlbeck/items/b8379971890edb755cac

CentOS
Cronがutcで動いてる場合に
http://yoshitsugufujii.github.io/blog/2016/02/03/change-crons-timezone/

Ubuntu
Ubuntu 20.04 LTSでタイムゾーンを変更する方法
https://viasnake.com/ubuntu-20-04-lts-change-timezone-cli/

Ubuntu
Ubuntu-Server 20.04でcron jobが動かない
https://qiita.com/higebobo/items/684bbb6a69702fc8b58b

0
0
0

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