快速修複Centos7 系統時區!,centos7時區

來源:互聯網
上載者:User

快速修複Centos7 系統時區!,centos7時區

注意:修改Linux系統的時區以後,再安裝jvm,jvm預設會使用系統的時區。
如果系統時區設定錯誤,安裝jvm後,再修改系統的時區,但jvm的時區仍然用不變,除非添加jvm的啟動參數:-D user.timezone=GMT+08

方法1: timedatectl set-timezone Asia/Shanghai
# timedatectlWarning: Ignoring the TZ variable. Reading the system's time zone setting only.Local time: Mon 2016-11-21 01:52:42 ESTUniversal time: Mon 2016-11-21 06:52:42 UTCRTC time: Mon 2016-11-21 06:52:42Time zone: America/New_York (EST, -0500)NTP enabled: n/aNTP synchronized: noRTC in local TZ: noDST active: noLast DST change: DST ended atSun 2016-11-06 01:59:59 EDTSun 2016-11-06 01:00:00 ESTNext DST change: DST begins (the clock jumps one hour forward) atSun 2017-03-12 01:59:59 ESTSun 2017-03-12 03:00:00 EDT

設定時區為CST(東8區)

# timedatectl  set-timezone Asia/ShanghaiWarning: Ignoring the TZ variable. Reading the system's time zone setting only.Local time: Mon 2016-11-21 14:52:59 CSTUniversal time: Mon 2016-11-21 06:52:59 UTCRTC time: Mon 2016-11-21 06:52:59Time zone: Asia/Shanghai (CST, +0800)NTP enabled: n/aNTP synchronized: noRTC in local TZ: noDST active: n/a[root@localhost ~]#
方法2:TZ環境變數的方式

修改使用者目錄下的.bash_profile,在檔案末尾追加:

TZ='Asia/Shanghai'; export TZ

推出登入後,重新登入,date命令可以查看效果。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.