Home>Article>Operation and Maintenance> What are the methods to change the system time zone in Centos7?
Two methods for modifying the system time zone in Centos7: 1. Use the timedatectl command to set and modify time zone information, the syntax is "timedatectl set-timezone time zone identification"; 2. Modify ".bash_profile" in the user directory file, append "TZ='time zone identifier'; export TZ" at the end of the file.
#The operating environment of this tutorial: centos7 system, thinkpad t480 computer.
Two methods to modify the Centos7 system time zone
Note: After modifying the time zone of the Linux system, and then install jvm, the jvm will use the system by default time zone.
If the system time zone is set incorrectly, after installing the jvm, modify the system time zone, but the jvm time zone will remain unchanged unless the jvm startup parameter is added: -D user.timezone=GMT 08
Method 1: timedatectl set-timezone Asia/Shanghai
timedatectl is a command under Linux, used to control the system time and date. It can be used to query and change the system clock and settings, and can also set and modify time zone information.
# 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 , append at the end of the file:
TZ='Asia/Shanghai'; export TZ
After logging out, log in again, and use the date command to see the effect.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What are the methods to change the system time zone in Centos7?. For more information, please follow other related articles on the PHP Chinese website!