如何禁用 ntpd?

如何禁用 ntpd?

我在虚拟机中运行 Ubuntu。如何禁用 ntpd?

答案1

要停止 ntpd:

sudo /etc/init.d/ntp stop

或者

sudo service ntp stop

为了防止它在启动时启动:

sudo update-rc.d -f ntp remove

答案2

使用 systemd 时,这两个命令是:

sudo systemctl stop ntp
sudo systemctl disable ntp

输出(我认为警告可以忽略)

ntp.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install disable ntp
insserv: warning: current start runlevel(s) (empty) of script `ntp' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (1 2 3 4 5) of script `ntp' overrides LSB defaults (1).
insserv: warning: current start runlevel(s) (empty) of script `ntp' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (1 2 3 4 5) of script `ntp' overrides LSB defaults (1).

查看:

systemctl is-enabled ntp

输出

ntp.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install is-enabled ntp
disabled

答案3

如果已安装 ntpd,请将其卸载。您仍会安装 ntpdate。(很难删除。)通过添加到 来阻止其exit 0执行/etc/default/ntpdate

更新:这是一个老答案。大多数系统现在都使用systemctl运行命令。要禁用 ntp 和 ntpdate,请发出以下命令:

systemctl disable ntp.service 
systemctl disable ntpdate.service 

您可以使用以下命令检查ntp相关单元的状态:

 systemctl list-unit-files | grep ntp    

相关内容