# Development/DevOps

[Ubuntu] 리눅스 우분투 timezone 설정

sokuli 2022. 5. 16. 10:04

리눅스 우분투 timezone 설정

AWS EC2 서버를 사용하면 기본 지역이 한국으로 되지 않기 때문에 서버 시간이 한국과 다르다.

 

우분투 timezone(서버 시간)은 'date' 명령어를 입력하면 확인할 수 있다.

ubuntu@SERVER:~/$ date
Mon May 16 00:12:41 UTC 2022

 

 

crontab과 같은 시간 예약 작업을 할 때 시간이 다르면 번거로우니 변경하도록 하자.

 

1. 'timedatectl' 명령어를 통해 변경할 수 있다.

ubuntu@SERVER:~/$ sudo timedatectl set-timezone 'Asia/Seoul'
ubuntu@SERVER:~/$ date
Sat May 16 19:52:25 KST 2020

 

2. 'tzslect' 명령어를 통해 변경하는 방법도 있다.

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

        Korea (South)

Therefore TZ='Asia/Seoul' will be used.
Selected time is now:   Mon May 16 09:14:31 KST 2022.
Universal Time is now:  Mon May 16 00:14:31 UTC 2022.
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

이후 위의 안내대로  .profile 파일에 설정 값들을 추가해주면 timezone이 변경된다.

ubuntu@SERVER:~/$ echo "TZ='Asia/Seoul'; export TZ" >> .profile
ubuntu@SERVER:~/$ source ~/.profile