40

This question shows how to stop automatic time update (and switch to manual):

How to stop automatic time update?

I want to do this exact thing but I can only ssh onto my machine so I need to make this change through the terminal. Is there any way to do this?

GeneralAsh
  • 503
  • 1
  • 4
  • 4
  • 4
    Possible duplicate of [how do I disable ntpd?](http://askubuntu.com/questions/29663/how-do-i-disable-ntpd) – Aizuddin Zali Oct 08 '15 at 15:23
  • 3
    @AizuddinZali I would say it isn't - since he gets errors telling him that ntp.service isn't loaded and `sudo /etc/init.d/ntp stop` doesn't work - see comments on my answer – TellMeWhy Oct 08 '15 at 15:41
  • yes, it has to do with gnome time & date setting. – Aizuddin Zali Oct 08 '15 at 15:42
  • Right, I'm just wondering id there's a way to change settings from terminal, or is there a file somewhere I need to change a line of? I tried 'conf watch /' while I changed the setting in the gui but it didn't show anything (but changing some other settings did) – GeneralAsh Oct 08 '15 at 15:57
  • ntp and GNOME Automatic Date & Time **isn't** the same. – A.B. Oct 08 '15 at 16:07
  • And it's not a dconf thing o_O – very interesting – A.B. Oct 08 '15 at 16:13
  • You could block the port on the outbound firewall. – Daniel Oct 08 '15 at 16:23

3 Answers3

74

GNOME Automatic Date & Time doesn't use the ntp service, installable via sudo apt-get install ntp. Therefore stopping or uninstalling the service doesn't help.

Systemd timedatectl is used, therefore one command to switch off

timedatectl set-ntp 0

and one command to switch on

timedatectl set-ntp 1

Example

enter image description here

% timedatectl set-ntp 1

enter image description here

or via 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
A.B.
  • 89,123
  • 21
  • 245
  • 323
  • Thank you! This is exactly what I was looking for. This is the setting that is changed when you switch between manual and automatic in the System Settings – GeneralAsh Oct 08 '15 at 16:27
  • the logs show it only synced when I restarted the service. do I need to create a cron to sync it every day? – jim smith Sep 28 '20 at 11:04
8

On a systemd operating system like Ubuntu 15.04 use the timedatectl utility, which makes the same Desktop Bus RPC calls as the GNOME control centre utility does:

timedatectl set-ntp false

Further reading

JdeBP
  • 3,931
  • 24
  • 38
4

What you are looking for is not ntpd which is not installed by default. It's an if-up.d script which run time update whenever a network interface activated.

dconf watch / shows nothing but inotifywait -m -r /etc/ will do.

/etc/network/if-up.d/ MOVED_FROM ntpdate
/etc/network/if-up.d/ MOVED_TO ntpdate.disabled

It belongs to ntpdate package.

$ dpkg -S /etc/network/if-up.d/ntpdate
ntpdate: /etc/network/if-up.d/ntpdate

So to disable time update, rename that file same as the control center does:

sudo mv /etc/network/if-up.d/ntpdate /etc/network/if-up.d/ntpdate.disabled
user.dz
  • 47,137
  • 13
  • 140
  • 258
  • 1
    I was also irritated, `dconf watch /` shows a change for the timezone, but not for the automatic date/time settings. Good one =) – A.B. Oct 08 '15 at 16:27