Two ways to change the Linux time zone

Source: Internet
Author: User
Tags local time

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.