annyoung

linux UTC to KST (also hardware time too) 본문

운영체제

linux UTC to KST (also hardware time too)

nopsled 2018. 6. 5. 10:29

매일매일 VM 셋팅해주면 region 때문에 time이 문제다.


아시아로 맞춰주면 UTC로 변하질 않나.. rdate로 타임서버랑 싱크 맞춰도 안맞질 않나... 짜증나서 열심히 삽질하다가 올려본다.


참고로 환경은 Ubuntu 16.04 LTS다.



nopsled@vmtest:~/$ ls -al /usr/share/zoneinfo/Asia | grep Seoul

lrwxrwxrwx  1 root root    6 Nov  9  2017 Seoul -> ../ROK

nopsled@vmtest:~/$ 



위와 같이 Seoul이 있는거 확인하면 된다. 참고로 환경이 Ubuntu라 경로가 바뀔 수 있음을 알아두자.



nopsled@vmtest:~/$ ls -al /etc/localtime

lrwxrwxrwx 1 root root 30 Jun  4 18:22 /etc/localtime -> /usr/share/zoneinfo/US/Pacific

nopsled@vmtest:~/$ 


/etc/localtime이 있는지 확인



nopsled@vmtest:~/$ sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

nopsled@vmtest:~/$ ls -al /etc/localtime

lrwxrwxrwx 1 root root 30 Jun  5 10:26 /etc/localtime -> /usr/share/zoneinfo/Asia/Seoul

nopsled@vmtest:~/$ date

Tue Jun  5 10:27:11 KST 2018

nopsled@vmtest:~/$ sudo hwclock --show

Tue 05 Jun 2018 10:27:13 AM KST  .956086 seconds

nopsled@vmtest:~/$ 


파일이 root 권한이므로 sudo로 링크 다시 걸어주고 제대로 적용되었는지 /etc/localtime을 확인


마지막으로 date와 sudo hwclock --show로 하드웨어 타임과 맞는지 확인하며 끝낸다.

Comments