본문 바로가기

OS/Linux

linux timezone 변경하기

최근 ec2 를 받아서 사용하는 경우가 많은데 전부 UTC 로 설정이 되어 있다.
개발이나 운영환경 전체에서 어떤 timezone 을 사용할 것인지 논의가 된적은 없지만
로그를 확인하다 보면 많이 불편했었는데

timezone 을 변경하는 것을 확인해 보았고 몇가지 방법이 있다.

timedatectl

system, permanent

sudo timedatectl set-timezone Asia/Seoul

/etc/localtime

system, permanent

sudo cp -p /usr/share/zoneinfo/Asia/Seoul /etc/localtime 

tzselect

per user, temporary

[test@ttest ~]$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
 1) Afghanistan           18) Israel                35) Palestine
 2) Armenia               19) Japan                 36) Philippines
 3) Azerbaijan            20) Jordan                37) Qatar
 4) Bahrain               21) Kazakhstan            38) Russia
 5) Bangladesh            22) Korea (North)         39) Saudi Arabia
 6) Bhutan                23) Korea (South)         40) Singapore
 7) Brunei                24) Kuwait                41) Sri Lanka
 8) Cambodia              25) Kyrgyzstan            42) Syria
 9) China                 26) Laos                  43) Taiwan
10) Cyprus                27) Lebanon               44) Tajikistan
11) East Timor            28) Macau                 45) Thailand
12) Georgia               29) Malaysia              46) Turkmenistan
13) Hong Kong             30) Mongolia              47) United Arab Emirates
14) India                 31) Myanmar (Burma)       48) Uzbekistan
15) Indonesia             32) Nepal                 49) Vietnam
16) Iran                  33) Oman                  50) Yemen
17) Iraq                  34) Pakistan
#? 23

The following information has been given:

        Korea (South)

Therefore TZ='Asia/Seoul' will be used.
Local time is now:      Tue Nov 24 12:04:02 KST 2020.
Universal Time is now:  Tue Nov 24 03:04:02 UTC 2020.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
        TZ='Asia/Seoul'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Seoul

env TZ

per user, temporary

# vi .profile or .bashrc
export TZ='Asia/Seoul'

사용자 별로 독립된 서비스를 하는 경우 tzselect, env TZ 를 사용하고
instance 전체에 같이 서비스를 한다면 timedatectl, /etc/localtime 을 사용하면 된다.

'OS > Linux' 카테고리의 다른 글

ubuntu 20.04 한영 한자 키 등록하기  (0) 2021.09.29
yum epel 404 error  (0) 2020.10.30
ssh 암호 없이 로그인하기  (0) 2020.02.11
man, 'No manual entry for man' 해결하기  (1) 2019.09.04