Centos7修改系統時區的兩種方法:1、使用timedatectl命令,可設定和修改時區信息,語法“timedatectl set-timezone 時區標識”;2、修改用戶目錄下的“.bash_profile”文件,在文件末尾追加“TZ='時區標識'; export TZ”即可。

本教學操作環境:centos7系統、thinkpad t480電腦。
修改Centos7系統時區的兩種方法
#注意:修改Linux系統的時區以後,再安裝jvm,jvm預設會使用系統的時區。
如果系統時區設定錯誤,安裝jvm後,再修改系統的時區,但jvm的時區仍會用不變,除非加入jvm的啟動參數:-D user.timezone=GMT 08
方法1:timedatectl set-timezone Asia/Shanghai
#timedatectl是Linux下的指令,用來控制系統時間和日期。可用來查詢和更改系統時鐘於設定,同時可以設定和修改時區資訊。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # 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
|
登入後複製
設定時區為CST(東8區)
1 2 3 4 5 6 7 8 9 10 11 12 | # 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 ~]#
|
登入後複製
#方法2:TZ環境變數的方式
修改使用者目錄下的.bash_profile ,在檔案結尾追加:
1 | TZ='Asia/Shanghai'; export TZ
|
登入後複製
退出登入後,重新登錄,date指令可以查看效果。
相關推薦:《Linux影片教學》
以上是Centos7改系統時區方法有哪些的詳細內容。更多資訊請關注PHP中文網其他相關文章!