[linux] timezone 설정하는 방법.

2022. 2. 8. 15:54OperatingSystem/linux

728x90
728x90

리눅스 타임존 설정하는 방법.(리눅스 서버 시간 설정하는 방법.)


-현재 설정된 타임존 확인하는 방법.

$ timedatectl

-설정 가능한 타임존 리스트 확인하는 방법.

$ timedatectl list-timezones

-특정 사용자(계정) time zone 설정하는 방법.

1.1.$ tzselect 수행.

$ 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:	2022. 02. 08. (화) 15:31:19 KST.
Universal Time is now:	2022. 02. 08. (화) 06:31:19 UTC.
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

1.2.사용자 환경 변수 설정.

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

-모든 사용자(계정) time zone 설정하는 방법.(1, 2 가지 가이드만 수행하면 됨.)

1.$ timedatectl set-timezone 수행.("Asia/Seoul" 타임존의 시간으로 서버 시간 셋팅.)

$ sudo timedatectl set-timezone Asia/Seoul

2."/usr/share/zoneinfo/Asia/Seoul" "/etc/localtime" 복사.

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