Amazon EC2에서 시간대를 설정하는 방법은 무엇입니까?
Ubuntu Linux를 실행하는 Amazon EC2 인스턴스에 설정된 시간대를 현지 시간으로 변경하고 싶습니다.
내 질문
Amazon EC2에서 시간대를 변경하는 방법은 무엇입니까?
데스크톱 Ubuntu 프로세스와 다르지 않아야합니다. 여기를 참조 하십시오
- EC2 서버에 대한 SSH
다음을 실행하십시오 (시간대를로 설정하려면
Australia/Adelaide
)$ echo "Australia/Adelaide" | sudo tee /etc/timezone Australia/Adelaide $ sudo dpkg-reconfigure --frontend noninteractive tzdata Current default time zone: 'Australia/Adelaide' Local time is now: Sat May 8 21:19:24 CST 2010. Universal Time is now: Sat May 8 11:49:24 UTC 2010.
최신 정보
tzselect
유틸리티를 사용 하여 탐색 할 수 있습니다 . 여기를 참조하십시오 : http://manpages.ubuntu.com/manpages/precise/man1/tzselect.1.html
대화 형 소프트웨어입니다. 내 Ubuntu (11.10)에 있습니다.
이 Wikipedia 기사를 참조 할 수도 있습니다.
브라질
Brazil/Acre
Brazil/DeNoronha
Brazil/East
Brazil/West
시간을 변경하는 또 다른 방법 (Amazon EC2 Linux 인스턴스에서 수행됨)
현지 시간 파일 제거
sudo rm /etc/localtime
ZoneInfo로 디렉토리 변경
cd /usr/share/zoneinfo
이 폴더에는 모든 시간대 정보가 포함되어 있습니다. 그런 다음 해당 영역으로 소프트 링크하기 만하면됩니다.
/ etc / localtime에 대한 소프트 링크 만들기
sudo ln -s /usr/share/zoneinfo/GB /etc/localtime
그러면 서버 시간대가 GB로 변경됩니다.
현재 시간대를 확인하십시오.
$ date
변경하려면 다음을 실행하십시오.
$ sudo dpkg-reconfigure tzdata
지리적 영역 목록이 표시됩니다. 사용 가능한 시간대를 좁히려면 선택합니다. 다음으로 도시 / 시간대를 선택하십시오. 그리고 시스템을 새로운 시간대로 변경했습니다.
ec2 머신의 시간대 변경에 대한 정보는 AWS 설명서 에서 확인할 수 있습니다. 자세한 내용은 아래에서 확인하세요.
시간대 변경
Amazon Linux 인스턴스는 기본적으로 UTC (협정 세계시) 시간대로 설정되지만 인스턴스의 시간을 현지 시간이나 네트워크의 다른 시간대로 변경할 수 있습니다.
인스턴스의 시간대를 변경하려면
1. 인스턴스에서 사용할 시간대를 식별합니다. / usr / share / zoneinfo 디렉토리에는 시간대 데이터 파일의 계층이 있습니다. 해당 위치에서 디렉토리 구조를 검색하여 시간대에 맞는 파일을 찾으십시오.
[ec2-user ~]$ ls /usr/share/zoneinfo
Africa Chile GB Indian Mideast posixrules US
America CST6CDT GB-Eire Iran MST PRC UTC
Antarctica Cuba GMT iso3166.tab MST7MDT PST8PDT WET
Arctic EET GMT0 Israel Navajo right W- SU
...
이 위치의 일부 항목은 디렉터리 (예 : America)이며 이러한 디렉터리에는 특정 도시의 시간대 파일이 포함되어 있습니다. 인스턴스에 사용할 도시 (또는 시간대의 도시)를 찾습니다. 이 예에서는 로스 앤젤레스의 시간대 파일 인 / usr / share / zoneinfo / America / Los_Angeles를 사용할 수 있습니다.
2. / etc / sysconfig / clock 파일을 새 시간대로 업데이트합니다.
a. 선호하는 텍스트 편집기 (예 : vim 또는 nano)로 / etc / sysconfig / clock 파일을 엽니 다. / etc / sysconfig / clock은 루트 소유이므로 편집기 명령과 함께 sudo를 사용해야합니다.
b. ZONE 항목을 찾아 표준 시간대 파일로 변경합니다 (경로의 / usr / share / zoneinfo 섹션 생략). 예를 들어, 로스 앤젤레스 시간대로 변경하려면 ZONE 항목을 다음과 같이 변경하십시오.
ZONE="America/Los_Angeles"
c. 파일을 저장하고 텍스트 편집기를 종료합니다.
3. / etc / localtime과 시간대 파일 사이에 심볼릭 링크를 생성하여 인스턴스가 현지 시간 정보를 참조 할 때 시간대 파일을 찾을 수 있도록합니다.
[ec2-user ~]$ sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
4. 시스템을 재부팅하여 모든 서비스 및 응용 프로그램에서 새 표준 시간대 정보를 선택합니다.
[ec2-user ~]$ sudo reboot
위의 단계 중 어느 것도 나를 위해 일하지 않았으므로 여기 에이 새 답변을 작성하는 것을 생각했습니다.
# Delete any existing localtime link
sudo rm /etc/localtime
# Update time clock file with ZONE property
sudo vi /etc/sysconfig/clock
#Update the ZONE property to what you want say
ZONE="America/Los_Angeles"
sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
sudo reboot
RHEL 7 관리자 가이드에서
이것이 REDHAT7의 명령 일 수 있습니다.
timedatectl set-timezone "Europe/Stockholm"
사용 가능한 모든 시간대를 가져 오려면 다음을 입력하십시오.
timedatectl list-timezone
더 많은 정보를 원하시면
man timedatectrl
UBUNTU 16.04에 대한 업데이트 된 답변 :
하다:
sudo timedatectl set-timezone America/New_York
시간대를 업데이트합니다.
사용 가능한 모든 시간대를 나열하려면 다음을 수행하십시오.
timedatectl list-timezones
Locate your timezone in the directory /usr/share/zoneinfo/
.
E.g. To change timezone for Toronto /usr/share/zoneinfo/America/Toronto
Symlink your timezone to /etc/localtime
e.g. for Toronto:
sudo ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime
Reboot to finish
reboot
NOTE: This refers to a linux box (debian in my instance) should be used under your AWS launch configurations "User Data".
If you're planning to set the TIMEZONE on instance boot use below (works like a charm) use you're own Country/City instead of "Australia/Sydney".
#!/bin/bash
/bin/rm -f /etc/localtime; /bin/ln -s /usr/share/zoneinfo/Australia/Sydney /etc/localtime
When you create a new EC2 instance and select "Amazon Linux 2 AMI (HVM)" as Amazon Machine Image (AMI), you can insert these lines in the "User Data" section. Based on which region you are in, change the second line with the timezone that works for you. I am in Central European Time (CET). Bear in mind that this bootstrap code is executed as root and only once when the instance is created.
#!/bin/bash
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/CET /etc/localtime
If you want to see all the other timezones available, ssh to one instance and run:
ls /usr/share/zoneinfo
참고URL : https://stackoverflow.com/questions/11931566/how-to-set-the-time-zone-in-amazon-ec2
'developer tip' 카테고리의 다른 글
document.write의 대안은 무엇입니까? (0) | 2020.11.27 |
---|---|
PHP stdObject에서 첫 번째 요소 가져 오기 (0) | 2020.11.26 |
치명적인 오류 : 포착되지 않은 오류 : 정의되지 않은 함수 mysql_connect () 호출 (0) | 2020.11.26 |
Double []을 double []로 어떻게 변환합니까? (0) | 2020.11.26 |
JavaScript에서 배열이 존재하는지 확인하는 방법은 무엇입니까? (0) | 2020.11.26 |