Home >System Tutorial >LINUX >Two methods to modify the system time zone of Centos7!

Two methods to modify the system time zone of Centos7!

WBOY
WBOYforward
2024-01-08 15:38:22618browse

两招修改​Centos7 系统时区!

Note: After modifying the time zone of the Linux system, and then installing jvm, the jvm will use the system time zone by default.
If the system time zone setting is wrong, after installing the jvm, you can modify the system time zone, but the jvm time zone will remain unchanged unless you add the jvm startup parameter: -D user.timezone=GMT 08

Method 1: timedatectl set-timezone Asia/Shanghai
# timedatectl
Warning: Ignoring the TZ variable. Reading the system's time zone setting only.

Local time: Mon 2016-11-21 01:52:42 EST
Universal time: Mon 2016-11-21 06:52:42 UTC
RTC time: Mon 2016-11-21 06:52:42
Time zone: America/New_York (EST, -0500)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2016-11-06 01:59:59 EDT
Sun 2016-11-06 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2017-03-12 01:59:59 EST
Sun 2017-03-12 03:00:00 EDT

Set the time zone to CST (East 8th District)

# timedatectl  set-timezone Asia/Shanghai
Warning: Ignoring the TZ variable. Reading the system's time zone setting only.

Local time: Mon 2016-11-21 14:52:59 CST
Universal time: Mon 2016-11-21 06:52:59 UTC
RTC time: Mon 2016-11-21 06:52:59
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost ~]#
Method 2: TZ environment variable method

Modify .bash_profile in the user directory and append:

at the end of the file
TZ='Asia/Shanghai'; export TZ

After launching the login, log in again and use the date command to check the effect.

The above is the detailed content of Two methods to modify the system time zone of Centos7!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete