Ubuntu 18.04 / 시간대(time zone) 설정하는 방법
우분투를 설치할 때 시간대 설정을 합니다. 그런데 AWS 같이 OS가 설치된 상태의 가상 서버를 사용하면, 서버의 시간대와 내가 원하는 시간대가 맞지 않을 수 있습니다. 시간대를 어떻게 설정하는지 알아보겠습니다.
현재 서버의 시간대 확인
현재 서버에 설정된 시간대는 date 명령어로 확인할 수 있습니다.
root@jb-dev-01:~# date Mon Dec 3 17:03:06 UTC 2018
시간대 설정 - 방법 1
시간대를 설정하고 싶다면 다음과 같이 명령합니다.
dpkg-reconfigure tzdata
한국이라면 Asia를 선택하고 Seoul을 선택합니다.
시간대 설정 - 방법 2
tzselect 명령으로 설정할 수 있습니다. 번호를 입력하여 시간대를 정합니다.
root@ubuntu-1804-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. #?
다음과 같은 질문이 나오면 1을 입력합니다.
Is the above information OK? 1) Yes 2) No #?
하지만, 적용시키기 위해서는 .profile을 수정해야 합니다.
You can make this change permanent for yourself by appending the line TZ='Africa/Algiers'; export TZ to the file '.profile' in your home directory; then log out and log in again.
따라서, 방법 1이 더 편합니다.