How to set the time zone in Amazon EC2?

后端 未结 11 1394
迷失自我
迷失自我 2020-12-22 19:33

I want to change the time zone set in my Amazon EC2 instance running Ubuntu Linux to local time?

My Question

How to change the time zone in

相关标签:
11条回答
  • 2020-12-22 19:33

    Information is available in aws documentation for changing the time zone in ec2 machine .Please find below the details :

    Changing the Time Zone

    Amazon Linux instances are set to the UTC (Coordinated Universal Time) time zone by default, but you may wish to change the time on an instance to the local time or to another time zone in your network.

    To change the time zone on an instance

    1.Identify the time zone to use on the instance. The /usr/share/zoneinfo directory contains a hierarchy of time zone data files. Browse the directory structure at that location to find a file for your time zone.

    [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
    ...
    

    Some of the entries at this location are directories (such as America), and these directories contain time zone files for specific cities. Find your city (or a city in your time zone) to use for the instance. In this example, you can use the time zone file for Los Angeles, /usr/share/zoneinfo/America/Los_Angeles.

    2.Update the /etc/sysconfig/clock file with the new time zone.

    a.Open the /etc/sysconfig/clock file with your favorite text editor (such as vim or nano). You need to use sudo with your editor command because /etc/sysconfig/clock is owned by root.

    b.Locate the ZONE entry, and change it to the time zone file (omitting the /usr/share/zoneinfo section of the path). For example, to change to the Los Angeles time zone, change the ZONE entry to the following.

    ZONE="America/Los_Angeles"
    

    c.Save the file and exit the text editor.

    3.Create a symbolic link between /etc/localtime and your time zone file so that the instance finds the time zone file when it references local time information.

    [ec2-user ~]$ sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
    

    4.Reboot the system to pick up the new time zone information in all services and applications.

    [ec2-user ~]$ sudo reboot
    
    0 讨论(0)
  • 2020-12-22 19:33

    from RHEL 7 admin guide

    Seems this might be the command on REDHAT7

    timedatectl set-timezone "Europe/Stockholm"
    

    To get all available timezones type:

    timedatectl list-timezone
    

    for more informations use

    man timedatectrl
    
    0 讨论(0)
  • 2020-12-22 19:37

    it should be no different than your desktop Ubuntu process. See here

    1. SSH to your EC2 server
    2. execute the following (to set timezone to 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.
      

    Update

    You can use tzselect utility to browse through. See here: http://manpages.ubuntu.com/manpages/precise/man1/tzselect.1.html

    It's an interactive software. My Ubuntu (11.10) has it.

    You could also refer this Wikipedia article

    Brazil

    Brazil/Acre
    Brazil/DeNoronha
    Brazil/East
    Brazil/West
    
    0 讨论(0)
  • 2020-12-22 19:38

    Well described in below link

    https://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line/594186#594186?s=8f7d09598b2246629a70bb1928501f52

    e:g- sudo timedatectl set-timezone Asia/Kolkata

    0 讨论(0)
  • 2020-12-22 19:39

    Check your current time zone by

    $ date
    

    To change it, run

    $ sudo dpkg-reconfigure tzdata
    

    This will show list of geographical areas. Select to narrow down available time zones. Next select city/timezone. And you have changed system to new timezone.

    0 讨论(0)
  • 2020-12-22 19:46

    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
    
    0 讨论(0)
提交回复
热议问题