Manually set time overwritten without a time sync active (in a VM)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm trying to set a fake time on Ubuntu 18.04 (systemd 237) for purposes of testing an execution of a monthly periodic task.



This is running on a virtual machine (virtualbox with guest additions).



The time resets itself back to correct time after a few seconds even though ntp syncing was disabled.



Example.



# Disable the sync
timedatectl set-ntp 0
# There aren't any ntp daemons running
systemctl -a | grep ntp # Returns nothing

# This confirms there is no sync active
timedatectl status
# Local time: Mo 2019-03-11 15:22:13 CET
# Universal time: Mo 2019-03-11 14:22:13 UTC
# RTC time: Mo 2019-03-11 14:22:13
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# Setting up the fake time
timedatectl set-time '2015-11-20 16:14:50'

# It worked! Wuhuu!
timedatectl status
# Local time: Fr 2015-11-20 16:14:51 CET
# Universal time: Fr 2015-11-20 15:14:51 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# 5 sec later
timedatectl status
# Local time: Mo 2019-03-11 15:25:35 CET
# Universal time: Mo 2019-03-11 14:25:35 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no


If there is no sychronisation service, what is keeping it in sync?










share|improve this question
























  • is this a VM with vmware tools installed?

    – Jeff Schaller
    Mar 11 at 14:39











  • @JeffSchaller Yup. Good catch, didn't think this would be important. Expanding the question. It's virtual box with guest additions actually.

    – TheMeaningfulEngineer
    Mar 11 at 14:50


















0















I'm trying to set a fake time on Ubuntu 18.04 (systemd 237) for purposes of testing an execution of a monthly periodic task.



This is running on a virtual machine (virtualbox with guest additions).



The time resets itself back to correct time after a few seconds even though ntp syncing was disabled.



Example.



# Disable the sync
timedatectl set-ntp 0
# There aren't any ntp daemons running
systemctl -a | grep ntp # Returns nothing

# This confirms there is no sync active
timedatectl status
# Local time: Mo 2019-03-11 15:22:13 CET
# Universal time: Mo 2019-03-11 14:22:13 UTC
# RTC time: Mo 2019-03-11 14:22:13
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# Setting up the fake time
timedatectl set-time '2015-11-20 16:14:50'

# It worked! Wuhuu!
timedatectl status
# Local time: Fr 2015-11-20 16:14:51 CET
# Universal time: Fr 2015-11-20 15:14:51 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# 5 sec later
timedatectl status
# Local time: Mo 2019-03-11 15:25:35 CET
# Universal time: Mo 2019-03-11 14:25:35 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no


If there is no sychronisation service, what is keeping it in sync?










share|improve this question
























  • is this a VM with vmware tools installed?

    – Jeff Schaller
    Mar 11 at 14:39











  • @JeffSchaller Yup. Good catch, didn't think this would be important. Expanding the question. It's virtual box with guest additions actually.

    – TheMeaningfulEngineer
    Mar 11 at 14:50














0












0








0








I'm trying to set a fake time on Ubuntu 18.04 (systemd 237) for purposes of testing an execution of a monthly periodic task.



This is running on a virtual machine (virtualbox with guest additions).



The time resets itself back to correct time after a few seconds even though ntp syncing was disabled.



Example.



# Disable the sync
timedatectl set-ntp 0
# There aren't any ntp daemons running
systemctl -a | grep ntp # Returns nothing

# This confirms there is no sync active
timedatectl status
# Local time: Mo 2019-03-11 15:22:13 CET
# Universal time: Mo 2019-03-11 14:22:13 UTC
# RTC time: Mo 2019-03-11 14:22:13
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# Setting up the fake time
timedatectl set-time '2015-11-20 16:14:50'

# It worked! Wuhuu!
timedatectl status
# Local time: Fr 2015-11-20 16:14:51 CET
# Universal time: Fr 2015-11-20 15:14:51 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# 5 sec later
timedatectl status
# Local time: Mo 2019-03-11 15:25:35 CET
# Universal time: Mo 2019-03-11 14:25:35 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no


If there is no sychronisation service, what is keeping it in sync?










share|improve this question
















I'm trying to set a fake time on Ubuntu 18.04 (systemd 237) for purposes of testing an execution of a monthly periodic task.



This is running on a virtual machine (virtualbox with guest additions).



The time resets itself back to correct time after a few seconds even though ntp syncing was disabled.



Example.



# Disable the sync
timedatectl set-ntp 0
# There aren't any ntp daemons running
systemctl -a | grep ntp # Returns nothing

# This confirms there is no sync active
timedatectl status
# Local time: Mo 2019-03-11 15:22:13 CET
# Universal time: Mo 2019-03-11 14:22:13 UTC
# RTC time: Mo 2019-03-11 14:22:13
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# Setting up the fake time
timedatectl set-time '2015-11-20 16:14:50'

# It worked! Wuhuu!
timedatectl status
# Local time: Fr 2015-11-20 16:14:51 CET
# Universal time: Fr 2015-11-20 15:14:51 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no

# 5 sec later
timedatectl status
# Local time: Mo 2019-03-11 15:25:35 CET
# Universal time: Mo 2019-03-11 14:25:35 UTC
# RTC time: Fr 2015-11-20 15:14:51
# Time zone: Europe/Berlin (CET, +0100)
# System clock synchronized: no
# systemd-timesyncd.service active: no
# RTC in local TZ: no


If there is no sychronisation service, what is keeping it in sync?







systemd date time






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 11 at 14:52







TheMeaningfulEngineer

















asked Mar 11 at 14:33









TheMeaningfulEngineerTheMeaningfulEngineer

1,81673776




1,81673776












  • is this a VM with vmware tools installed?

    – Jeff Schaller
    Mar 11 at 14:39











  • @JeffSchaller Yup. Good catch, didn't think this would be important. Expanding the question. It's virtual box with guest additions actually.

    – TheMeaningfulEngineer
    Mar 11 at 14:50


















  • is this a VM with vmware tools installed?

    – Jeff Schaller
    Mar 11 at 14:39











  • @JeffSchaller Yup. Good catch, didn't think this would be important. Expanding the question. It's virtual box with guest additions actually.

    – TheMeaningfulEngineer
    Mar 11 at 14:50

















is this a VM with vmware tools installed?

– Jeff Schaller
Mar 11 at 14:39





is this a VM with vmware tools installed?

– Jeff Schaller
Mar 11 at 14:39













@JeffSchaller Yup. Good catch, didn't think this would be important. Expanding the question. It's virtual box with guest additions actually.

– TheMeaningfulEngineer
Mar 11 at 14:50






@JeffSchaller Yup. Good catch, didn't think this would be important. Expanding the question. It's virtual box with guest additions actually.

– TheMeaningfulEngineer
Mar 11 at 14:50











2 Answers
2






active

oldest

votes


















2















If there is no sychronisation service, […]




But there is. It is built into the VirtualBox service that runs in the guest operating system.



The VBoxService service in the guest operating system unfortunately does a lot of things all in one, and stopping it entirely eliminates everything that it does. The only fine-grained control available, since control via native service management tools is not, is Oracle's tool:


VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1


This does not disable the synchronization service thread per se. It makes the hypervisor call that the thread invokes return failure. The synchronization service thread continues to run. It just repeatedly fails to obtain the host time.



Further reading



  • Michael Biebl (2016-01-24). Disable systemd-timesyncd in VirtualBox guests. Debian bug #812522.

  • "Fine Tuning Timers and Time Synchronization". Oracle VM VirtualBox User Manual. Oracle. 2019.





share|improve this answer






























    0














    This seems to be caused by a service from the VM to sync with the host system.
    In my case (Virtualbox) disabling the service solved the problem.



    systemctl stop vboxadd-service.service


    There are more sophisticated solutions specified in other answers/comments but they require executing a step on the host side.
    For my case this was simpler to document given that all the testing related to this mock needs to be executed on the guest.






    share|improve this answer

























    • consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

      – Jeff Schaller
      Mar 11 at 15:28











    • @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

      – TheMeaningfulEngineer
      Mar 11 at 16:52











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f505650%2fmanually-set-time-overwritten-without-a-time-sync-active-in-a-vm%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2















    If there is no sychronisation service, […]




    But there is. It is built into the VirtualBox service that runs in the guest operating system.



    The VBoxService service in the guest operating system unfortunately does a lot of things all in one, and stopping it entirely eliminates everything that it does. The only fine-grained control available, since control via native service management tools is not, is Oracle's tool:


    VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1


    This does not disable the synchronization service thread per se. It makes the hypervisor call that the thread invokes return failure. The synchronization service thread continues to run. It just repeatedly fails to obtain the host time.



    Further reading



    • Michael Biebl (2016-01-24). Disable systemd-timesyncd in VirtualBox guests. Debian bug #812522.

    • "Fine Tuning Timers and Time Synchronization". Oracle VM VirtualBox User Manual. Oracle. 2019.





    share|improve this answer



























      2















      If there is no sychronisation service, […]




      But there is. It is built into the VirtualBox service that runs in the guest operating system.



      The VBoxService service in the guest operating system unfortunately does a lot of things all in one, and stopping it entirely eliminates everything that it does. The only fine-grained control available, since control via native service management tools is not, is Oracle's tool:


      VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1


      This does not disable the synchronization service thread per se. It makes the hypervisor call that the thread invokes return failure. The synchronization service thread continues to run. It just repeatedly fails to obtain the host time.



      Further reading



      • Michael Biebl (2016-01-24). Disable systemd-timesyncd in VirtualBox guests. Debian bug #812522.

      • "Fine Tuning Timers and Time Synchronization". Oracle VM VirtualBox User Manual. Oracle. 2019.





      share|improve this answer

























        2












        2








        2








        If there is no sychronisation service, […]




        But there is. It is built into the VirtualBox service that runs in the guest operating system.



        The VBoxService service in the guest operating system unfortunately does a lot of things all in one, and stopping it entirely eliminates everything that it does. The only fine-grained control available, since control via native service management tools is not, is Oracle's tool:


        VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1


        This does not disable the synchronization service thread per se. It makes the hypervisor call that the thread invokes return failure. The synchronization service thread continues to run. It just repeatedly fails to obtain the host time.



        Further reading



        • Michael Biebl (2016-01-24). Disable systemd-timesyncd in VirtualBox guests. Debian bug #812522.

        • "Fine Tuning Timers and Time Synchronization". Oracle VM VirtualBox User Manual. Oracle. 2019.





        share|improve this answer














        If there is no sychronisation service, […]




        But there is. It is built into the VirtualBox service that runs in the guest operating system.



        The VBoxService service in the guest operating system unfortunately does a lot of things all in one, and stopping it entirely eliminates everything that it does. The only fine-grained control available, since control via native service management tools is not, is Oracle's tool:


        VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1


        This does not disable the synchronization service thread per se. It makes the hypervisor call that the thread invokes return failure. The synchronization service thread continues to run. It just repeatedly fails to obtain the host time.



        Further reading



        • Michael Biebl (2016-01-24). Disable systemd-timesyncd in VirtualBox guests. Debian bug #812522.

        • "Fine Tuning Timers and Time Synchronization". Oracle VM VirtualBox User Manual. Oracle. 2019.






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 11 at 15:41









        JdeBPJdeBP

        37.9k478183




        37.9k478183























            0














            This seems to be caused by a service from the VM to sync with the host system.
            In my case (Virtualbox) disabling the service solved the problem.



            systemctl stop vboxadd-service.service


            There are more sophisticated solutions specified in other answers/comments but they require executing a step on the host side.
            For my case this was simpler to document given that all the testing related to this mock needs to be executed on the guest.






            share|improve this answer

























            • consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

              – Jeff Schaller
              Mar 11 at 15:28











            • @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

              – TheMeaningfulEngineer
              Mar 11 at 16:52















            0














            This seems to be caused by a service from the VM to sync with the host system.
            In my case (Virtualbox) disabling the service solved the problem.



            systemctl stop vboxadd-service.service


            There are more sophisticated solutions specified in other answers/comments but they require executing a step on the host side.
            For my case this was simpler to document given that all the testing related to this mock needs to be executed on the guest.






            share|improve this answer

























            • consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

              – Jeff Schaller
              Mar 11 at 15:28











            • @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

              – TheMeaningfulEngineer
              Mar 11 at 16:52













            0












            0








            0







            This seems to be caused by a service from the VM to sync with the host system.
            In my case (Virtualbox) disabling the service solved the problem.



            systemctl stop vboxadd-service.service


            There are more sophisticated solutions specified in other answers/comments but they require executing a step on the host side.
            For my case this was simpler to document given that all the testing related to this mock needs to be executed on the guest.






            share|improve this answer















            This seems to be caused by a service from the VM to sync with the host system.
            In my case (Virtualbox) disabling the service solved the problem.



            systemctl stop vboxadd-service.service


            There are more sophisticated solutions specified in other answers/comments but they require executing a step on the host side.
            For my case this was simpler to document given that all the testing related to this mock needs to be executed on the guest.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 11 at 16:54

























            answered Mar 11 at 15:12









            TheMeaningfulEngineerTheMeaningfulEngineer

            1,81673776




            1,81673776












            • consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

              – Jeff Schaller
              Mar 11 at 15:28











            • @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

              – TheMeaningfulEngineer
              Mar 11 at 16:52

















            • consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

              – Jeff Schaller
              Mar 11 at 15:28











            • @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

              – TheMeaningfulEngineer
              Mar 11 at 16:52
















            consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

            – Jeff Schaller
            Mar 11 at 15:28





            consider less-drastic solutions like virtualbox.org/manual/ch09.html#fine-tune-timers -- VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1; also superuser.com/q/984040/513541

            – Jeff Schaller
            Mar 11 at 15:28













            @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

            – TheMeaningfulEngineer
            Mar 11 at 16:52





            @JeffSchaller Thanks, but they are more complicated to document given that they require host execution.

            – TheMeaningfulEngineer
            Mar 11 at 16:52

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f505650%2fmanually-set-time-overwritten-without-a-time-sync-active-in-a-vm%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)