Gen*_*Ash 31 command-line time date
这个问题显示了如何停止自动时间更新(并切换到手动):
我想做这件事,但我只能 ssh 到我的机器上,所以我需要通过终端进行此更改。有没有办法做到这一点?
A.B*_*.B. 59
GNOME Automatic Date & Time 不使用 ntp 服务,可通过sudo apt-get install ntp
. 因此,停止或卸载该服务无济于事。
使用 Systemd timedatectl
,因此一个命令可以关闭
timedatectl set-ntp 0
Run Code Online (Sandbox Code Playgroud)
和一个打开命令
timedatectl set-ntp 1
Run Code Online (Sandbox Code Playgroud)
例子
% timedatectl set-ntp 1
Run Code Online (Sandbox Code Playgroud)
或通过 timedatectl status
% timedatectl status
Local time: Do 2015-10-08 18:17:17 CEST
Universal time: Do 2015-10-08 16:17:17 UTC
RTC time: Do 2015-10-08 16:17:17
Time zone: Europe/Berlin (CEST, +0200)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
So 2015-03-29 01:59:59 CET
So 2015-03-29 03:00:00 CEST
Next DST change: DST ends (the clock jumps one hour backwards) at
So 2015-10-25 02:59:59 CEST
So 2015-10-25 02:00:00 CET
% timedatectl set-ntp 1
% timedatectl status
Local time: Do 2015-10-08 18:17:35 CEST
Universal time: Do 2015-10-08 16:17:35 UTC
RTC time: Do 2015-10-08 16:17:35
Time zone: Europe/Berlin (CEST, +0200)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
So 2015-03-29 01:59:59 CET
So 2015-03-29 03:00:00 CEST
Next DST change: DST ends (the clock jumps one hour backwards) at
So 2015-10-25 02:59:59 CEST
So 2015-10-25 02:00:00 CET
Run Code Online (Sandbox Code Playgroud)
在像 Ubuntu 15.04 这样的 systemd 操作系统上使用该timedatectl
实用程序,它进行与 GNOME 控制中心实用程序相同的桌面总线 RPC 调用:
timedatectl set-ntp false
Run Code Online (Sandbox Code Playgroud)
timedatectl
. Ubuintu 15.04 手册页。典范。timedatectl
. systemd 手册页。Freedesktop.org。您正在寻找的不是ntpd
默认情况下未安装的。这是一个if-up.d
每当网络接口激活时运行时更新的脚本。
dconf watch /
没有表现出什么,但inotifywait -m -r /etc/
会做。这是有趣的输出:
/etc/network/if-up.d/ MOVED_FROM ntpdate
/etc/network/if-up.d/ MOVED_TO ntpdate.disabled
Run Code Online (Sandbox Code Playgroud)
它属于ntpdate包。
$ dpkg -S /etc/network/if-up.d/ntpdate
ntpdate: /etc/network/if-up.d/ntpdate
Run Code Online (Sandbox Code Playgroud)
因此,要禁用时间更新,请将该文件重命名为与控制中心相同的名称:
sudo mv /etc/network/if-up.d/ntpdate /etc/network/if-up.d/ntpdate.disabled
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
109482 次 |
最近记录: |