Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google compute engine instances timezone changed to UTC automatically

I'm a new user of GCE instances.

I created instances a week ago and changed timezone to Asia/Shanghai by commands below: cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Then yesterday, I found that my system timezone changed to UTC automatically and /etc/localtime was changed. So I run the command above agina. Until now it's OK.

After that I checked many resources and export TZ='Asia/Shanghai'. But I still not know if it's the root cause or not.

Also I find that someone adds xen.independent_wallclock=1 in sysctl.conf file to maintain independent times. But it's for Xen VM and I'm not sure if it's useful for GCE.

Could anyone please take a look at it ?

like image 914
user3678651 Avatar asked Dec 04 '22 06:12

user3678651


2 Answers

I've found a more user friendly approach here

Go root user

sudo -s

and use

dpkg-reconfigure tzdata

This will bring up a GUI which will guide you to change your timezone information

like image 115
Maviles Avatar answered Jan 13 '23 13:01

Maviles


To make the permanent change edit $HOME/.profile or $HOME/.bash_profile appending the line and then log out and log in again:

TZ='Asia/Shanghai'; export TZ

like image 27
Faizan Avatar answered Jan 13 '23 12:01

Faizan