The default time zone for a Linux virtual machine on Azure is UTC when it is started. It is very inconvenient for many applications to record timestamps.
This article describes two ways to change the time stamp of Linux for your reference.
1. Modify the/etc/localtime file
The file that controls the system time zone is/etc/localtime. As long as the file is copied into the corresponding time zone files, the system time zone is changed to the corresponding times.
Time zone information in:/usr/share/zoneinfo. For example, you need to change the time zone to Shanghai:
Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime
Ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime
All two instructions can be changed.
2. Modify the TZ variable
Eport can see system variables. If the TZ variable is set, the system sets the local time zone by the variable of TZ. And the priority is higher than/etc/localtime.
The specific order is export Tz=asia/shanghai
The command to cancel this variable is unset TZ
The current time can be viewed by date.
Two ways to change the Linux time zone