linux指令timedatectl,centos7设置时间命令timedatectl

在新的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参数进行远程主机的时间设置。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值