Glam Prestige Journal

Bright entertainment trends with youth appeal.

I have a virtual machine that is set to PST that a couple of colleagues have in different time-zones.

If I wanted to change the time-zone to EST and GMT, what do I need to do?

1

10 Answers

Use timedatectl

sudo timedatectl set-timezone <timeszone>

Examples:

  • Timezone as EST

    sudo timedatectl set-timezone EST
  • Timezone as UTC

    sudo timedatectl set-timezone UTC
  • Listing all valid Timezones

    timedatectl list-timezones

This command is perfect for automation scripts since it doesn't require any user interaction while compared to the other given answer based on dpkg-reconfigure tzdata.

12

As root you have to execute:

dpkg-reconfigure tzdata

A menu based tool should be started that allows you to change the timezone.

The following also work. For GMT:

ln -sf /usr/share/zoneinfo/GMT /etc/localtime

For EST:

ln -sf /usr/share/zoneinfo/EST /etc/localtime
4

The most ease way especially to a server is to list timezones:

timedatectl list-timezones

And choose yours, for example:

timedatectl set-timezone Europe/Athens

Thats it! , :-)

Edit the timezone file at the /etc folder as:

Etc/GMT

You can use the next format:

Region "/" City 

Example of /etc/timezone:

Europe/Athens

or

Europe/Paris
Europe/London

You may experiment with the: dpkg-reconfigure tzdataand check cat the timezone file.

You must reboot or start again a service (not the ntp service). I do not know which one. If somebody knows please share with us. (Tested on Ubuntu 15.10 the change is taken into account instantly)

To run one program with a different time zone setting, set the TZ environment variable, e.g. run TZ=Pacific/Kiritimati date to see what time it is on Christmas Island, or export TZ=Pacific/Kiritimati to have the setting last for a shell session.

cp -p /usr/share/zoneinfo/US/Pacific /etc/localtime

I recommend AGAINST linking like mentioned by others. If some script accidentally over writes your /etc/localtime file, then it overwrites your Pacific timezone file... and it's a bit of a pain to replace it.

Just copy the Pacific file over the localtime file with the command above.

1

I use the following script to ask the user which timezone to set, and then confirm it has indeed been set:

#!/bin/sh
sudo timedatectl set-timezone $(tzselect)
echo
echo timedatectl says:
timedatectl

I call it tz-set.

As root you have to execute:

ln -fs /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && dpkg-reconfigure --frontend noninteractive tzdata

2

This worked for me on GCP Ubuntu 14 via SSH

  1. sudo su
  2. cp /usr/share/zoneinfo/Asia/Singapore /etc/localtime
  3. Restart the server
  4. Done

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy