3

This question may have been asked before but I couldn't find the answer.

I want to set the time with the following command to set the time + 6 hours from now

 sudo date -s "6 hours"

The problem is that after a couple of seconds it changes the time back to normal automatically.

How can I stop that? I'm using Ubuntu 16.04.

Schidu Luca
  • 133
  • 1
  • 6
  • 3
    Possible duplicate of [How to stop automatic time update?](http://askubuntu.com/questions/176174/how-to-stop-automatic-time-update) – You'reAGitForNotUsingGit Nov 29 '16 at 15:56
  • Doesn't work, I tried that – Schidu Luca Nov 29 '16 at 16:01
  • I'm wondering if this has something to do with `ntpd`, the Netowrk Time Protocol Daemon that keeps the system clock sync'ed with internet servers. I'm not sure if it could be as simple as "apt-get remove"-ing ntpd, or if it's a bit more complicated than that – Nick Weinberg Nov 29 '16 at 16:18

1 Answers1

2

From what I understand, the core functions of ntpd have been replaced with timesyncd and timedatectl in that version of Ubuntu, as outlined in the documentation found in the link below:

https://help.ubuntu.com/lts/serverguide/NTP.html

If you run the command timedatectl you'll see data in the following format:

chris@loki:/$ timedatectl
      Local time: Wed 2016-11-30 11:18:42 GMT
  Universal time: Wed 2016-11-30 11:18:42 UTC
        RTC time: Wed 2016-11-30 11:18:40
       Time zone: Europe/London (GMT, +0000)
 Network time on: yes
NTP synchronized: no
 RTC in local TZ: no

I ran the following to disable NTP synchronization:

timedatectl set-ntp 0

But I still wasn't able to change the time, as below:

chris@loki:/$ sudo timedatectl set-time "2015-11-08 07:14:00"
Failed to set time: Automatic time synchronization is enabled

I was only able to update this once I'd gone to Settings > Date & Time and disabled Network Time. Not sure where the config file is for that though to do via cli.

The result:

chris@loki:/$ timedatectl status
      Local time: Wed 2016-11-30 11:31:33 GMT
  Universal time: Wed 2016-11-30 11:31:33 UTC
        RTC time: Wed 2016-11-30 11:31:31
       Time zone: Europe/London (GMT, +0000)
 Network time on: no
NTP synchronized: no
 RTC in local TZ: no

chris@loki:/$ sudo timedatectl set-time "2014-11-08 06:40:00"

chris@loki:/$ timedatectl status
          Local time: Sat 2014-11-08 06:40:02 GMT
      Universal time: Sat 2014-11-08 06:40:02 UTC
            RTC time: Sat 2014-11-08 06:40:03
           Time zone: Europe/London (GMT, +0000)
     Network time on: no
    NTP synchronized: no
     RTC in local TZ: no