centos 7 設定時間命令timedatectl用法樣本

來源:互聯網
上載者:User

在新的centos7裡,關於時間的指令除了保留了之前版本中常用到的date、hwclock等命令外,還增加了一個統一的命令timedatactl。下面結合其用法進行下小結。

查看 timedatectl 指令用法協助

 代碼如下 複製代碼
[root@361way ~]# timedatectl --help
timedatectl [OPTIONS...] COMMAND ...
Query or change system time and date settings.
  -h --help              Show this help
     --version           Show package version
     --adjust-system-clock
                         Adjust system clock when changing local RTC mode
     --no-pager          Do not pipe output into a pager
  -P --privileged        Acquire privileges before execution
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
Commands:
  status                 Show current time settings
  set-time TIME          Set system time
  set-timezone ZONE      Set system timezone
  list-timezones         Show known timezones
  set-local-rtc BOOL     Control whether RTC is in local time
  set-ntp BOOL           Control whether NTP is enabled


更詳細的協助資訊也可以通過man timedatectl 進行查看。

查看當前設定,直接輸入timedatectl等同於timedatectl status

 代碼如下 複製代碼
[root@361way ~]# timedatectl
      Local time: Wed 2014-09-24 21:19:26 CST
  Universal time: Wed 2014-09-24 13:19:26 UTC
        RTC time: Wed 2014-09-24 13:19:26
        Timezone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a


設定日期

timedatectl set-time YYYY-MM-DD
設定目前時間

timedatectl set-time HH:MM:SS
預設的,系統是使用UTC時間的,可以用以下命令開啟和關閉UTC時間:

timedatectl set-local-rtc boolean
把 boolean 替換成yes則表示使用本地時間,替換成no則表示是UTC時間

註:這裡的boolean值也可以用true、flase

設定時區:

查看所有的時區:

timedatectl list-timezones
用以下命令設定時區:

timedatectl set-timezone time_zone
遠程NTP伺服器同步

timedatectl還可以設定是否開啟NTP選項

timedatectl set-ntp boolean
這裡的boolean是yes或者no

除了以上用法,timedatectl 還支援通過-H參數進行遠程主機的時間設定。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.