How best to ensure unattended-upgrades runs regularly on a nomadic laptop?How to customize...

Is camera lens focus an exact point or a range?

Should I stop contributing to retirement accounts?

Do the concepts of IP address and network interface not belong to the same layer?

Would it be legal for a US State to ban exports of a natural resource?

Reply 'no position' while the job posting is still there

Why does Async/Await work properly when the loop is inside the async function and not the other way around?

How do I repair my stair bannister?

Is a model fitted to data or is data fitted to a model?

Journal losing indexing services

Is it possible to have a strip of cold climate in the middle of a planet?

Difference between -| and |- in TikZ

Is there a conventional notation or name for the slip angle?

Why did the EU agree to delay the Brexit deadline?

Flux received by a negative charge

Can I use my Chinese passport to enter China after I acquired another citizenship?

When quoting, must I also copy hyphens used to divide words that continue on the next line?

Why has "pence" been used in this sentence, not "pences"?

Visiting the UK as unmarried couple

Longest common substring in linear time

Diode in opposite direction?

Ridge Regression with Gradient Descent Converges to OLS estimates

THT: What is a squared annular “ring”?

Can somebody explain Brexit in a few child-proof sentences?

What linear sensor for a keyboard?



How best to ensure unattended-upgrades runs regularly on a nomadic laptop?


How to customize unattended-upgrades notification emails?Cannot get unattended-upgrades to workunattended-upgrades error: “/etc/cron.daily/apt: DB Update failed, database locked”confusion about cron and anacron (setting up backup schedule for rsnapshot)Ubuntu 16.04: Unattended-upgrades runs at random timesUnattended upgrades status?unattended upgrades - which shutdown command works?Configuring unattended-upgrades Helpunattended-upgrades runs twice every day but never installs anythingSet unattended-upgrades non-interactively













0















APT seems to have an enduring blind-spot for computers which are not connected permanently to the internet. These days there are surely a ton of them, mostly laptops.



The general solution is unattended-upgrades. This is installed and run by default with a daily cron job. As a protection, anacron is also installed and run by default, and executes any cron jobs which were missed because the computer was turned off. So far so sensible.



BUT!





  1. Default unattended-upgrades config (/etc/apt/apt.conf.d/50unattended-upgrades or similar) requires the following to be set, else upgrades risk being skipped:



    Unattended-Upgrade::OnlyOnACPower "false";
    Unattended-Upgrade::Skip-Updates-On-Metered-Connections "false";


  2. More importantly, anacron, like cron, runs jobs whether or not an internet connection is available! This is clearly a major design bug for non-server Ubuntu, since personal computers are not always connected permanently. With default config, on a nomadic laptop, unattended-upgrades will simply fail much of the time.



(Perhaps there needs to be a separate class of cron job which waits for a network connection until executing. Or failed cron.daily jobs could be switched to cron.hourly until they execute successfully.)



One practical solution is a systemd unit file to execute unattended-upgrades as a user script after the network comes online. But it will only run once per boot.



What is the optimal solution? Does anyone know if there are plans to fix this with a new package or a config improvement?









share



























    0















    APT seems to have an enduring blind-spot for computers which are not connected permanently to the internet. These days there are surely a ton of them, mostly laptops.



    The general solution is unattended-upgrades. This is installed and run by default with a daily cron job. As a protection, anacron is also installed and run by default, and executes any cron jobs which were missed because the computer was turned off. So far so sensible.



    BUT!





    1. Default unattended-upgrades config (/etc/apt/apt.conf.d/50unattended-upgrades or similar) requires the following to be set, else upgrades risk being skipped:



      Unattended-Upgrade::OnlyOnACPower "false";
      Unattended-Upgrade::Skip-Updates-On-Metered-Connections "false";


    2. More importantly, anacron, like cron, runs jobs whether or not an internet connection is available! This is clearly a major design bug for non-server Ubuntu, since personal computers are not always connected permanently. With default config, on a nomadic laptop, unattended-upgrades will simply fail much of the time.



    (Perhaps there needs to be a separate class of cron job which waits for a network connection until executing. Or failed cron.daily jobs could be switched to cron.hourly until they execute successfully.)



    One practical solution is a systemd unit file to execute unattended-upgrades as a user script after the network comes online. But it will only run once per boot.



    What is the optimal solution? Does anyone know if there are plans to fix this with a new package or a config improvement?









    share

























      0












      0








      0








      APT seems to have an enduring blind-spot for computers which are not connected permanently to the internet. These days there are surely a ton of them, mostly laptops.



      The general solution is unattended-upgrades. This is installed and run by default with a daily cron job. As a protection, anacron is also installed and run by default, and executes any cron jobs which were missed because the computer was turned off. So far so sensible.



      BUT!





      1. Default unattended-upgrades config (/etc/apt/apt.conf.d/50unattended-upgrades or similar) requires the following to be set, else upgrades risk being skipped:



        Unattended-Upgrade::OnlyOnACPower "false";
        Unattended-Upgrade::Skip-Updates-On-Metered-Connections "false";


      2. More importantly, anacron, like cron, runs jobs whether or not an internet connection is available! This is clearly a major design bug for non-server Ubuntu, since personal computers are not always connected permanently. With default config, on a nomadic laptop, unattended-upgrades will simply fail much of the time.



      (Perhaps there needs to be a separate class of cron job which waits for a network connection until executing. Or failed cron.daily jobs could be switched to cron.hourly until they execute successfully.)



      One practical solution is a systemd unit file to execute unattended-upgrades as a user script after the network comes online. But it will only run once per boot.



      What is the optimal solution? Does anyone know if there are plans to fix this with a new package or a config improvement?









      share














      APT seems to have an enduring blind-spot for computers which are not connected permanently to the internet. These days there are surely a ton of them, mostly laptops.



      The general solution is unattended-upgrades. This is installed and run by default with a daily cron job. As a protection, anacron is also installed and run by default, and executes any cron jobs which were missed because the computer was turned off. So far so sensible.



      BUT!





      1. Default unattended-upgrades config (/etc/apt/apt.conf.d/50unattended-upgrades or similar) requires the following to be set, else upgrades risk being skipped:



        Unattended-Upgrade::OnlyOnACPower "false";
        Unattended-Upgrade::Skip-Updates-On-Metered-Connections "false";


      2. More importantly, anacron, like cron, runs jobs whether or not an internet connection is available! This is clearly a major design bug for non-server Ubuntu, since personal computers are not always connected permanently. With default config, on a nomadic laptop, unattended-upgrades will simply fail much of the time.



      (Perhaps there needs to be a separate class of cron job which waits for a network connection until executing. Or failed cron.daily jobs could be switched to cron.hourly until they execute successfully.)



      One practical solution is a systemd unit file to execute unattended-upgrades as a user script after the network comes online. But it will only run once per boot.



      What is the optimal solution? Does anyone know if there are plans to fix this with a new package or a config improvement?







      laptop unattended-upgrades anacron





      share












      share










      share



      share










      asked 2 mins ago









      SqerstetSqerstet

      183211




      183211






















          1 Answer
          1






          active

          oldest

          votes


















          0














          If connecting to internet with network-manager, the current default on Ubuntu, then create a dispatcher script to launch unattended-upgrades after connecting to the network:



          sudo touch /etc/NetworkManager/dispatcher.d/20-myconnectionscript
          sudo chmod +x /etc/NetworkManager/dispatcher.d/20-myconnectionscript


          In 20-myconnectionscript:



          #!/bin/sh

          if [ "$2" = "up" ];
          # only proceed if unattended-upgrades was last run more than a day ago
          ELAPSEDSINCEUU=$(($(date +%s) - $(date +%s -r /var/lib/apt/periodic/unattended-upgrades-stamp)))
          if [ $ELAPSEDSINCEUU -gt 86400 ]; then
          /usr/bin/unattended-upgrades
          fi
          fi




          share























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2faskubuntu.com%2fquestions%2f1128433%2fhow-best-to-ensure-unattended-upgrades-runs-regularly-on-a-nomadic-laptop%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            If connecting to internet with network-manager, the current default on Ubuntu, then create a dispatcher script to launch unattended-upgrades after connecting to the network:



            sudo touch /etc/NetworkManager/dispatcher.d/20-myconnectionscript
            sudo chmod +x /etc/NetworkManager/dispatcher.d/20-myconnectionscript


            In 20-myconnectionscript:



            #!/bin/sh

            if [ "$2" = "up" ];
            # only proceed if unattended-upgrades was last run more than a day ago
            ELAPSEDSINCEUU=$(($(date +%s) - $(date +%s -r /var/lib/apt/periodic/unattended-upgrades-stamp)))
            if [ $ELAPSEDSINCEUU -gt 86400 ]; then
            /usr/bin/unattended-upgrades
            fi
            fi




            share




























              0














              If connecting to internet with network-manager, the current default on Ubuntu, then create a dispatcher script to launch unattended-upgrades after connecting to the network:



              sudo touch /etc/NetworkManager/dispatcher.d/20-myconnectionscript
              sudo chmod +x /etc/NetworkManager/dispatcher.d/20-myconnectionscript


              In 20-myconnectionscript:



              #!/bin/sh

              if [ "$2" = "up" ];
              # only proceed if unattended-upgrades was last run more than a day ago
              ELAPSEDSINCEUU=$(($(date +%s) - $(date +%s -r /var/lib/apt/periodic/unattended-upgrades-stamp)))
              if [ $ELAPSEDSINCEUU -gt 86400 ]; then
              /usr/bin/unattended-upgrades
              fi
              fi




              share


























                0












                0








                0







                If connecting to internet with network-manager, the current default on Ubuntu, then create a dispatcher script to launch unattended-upgrades after connecting to the network:



                sudo touch /etc/NetworkManager/dispatcher.d/20-myconnectionscript
                sudo chmod +x /etc/NetworkManager/dispatcher.d/20-myconnectionscript


                In 20-myconnectionscript:



                #!/bin/sh

                if [ "$2" = "up" ];
                # only proceed if unattended-upgrades was last run more than a day ago
                ELAPSEDSINCEUU=$(($(date +%s) - $(date +%s -r /var/lib/apt/periodic/unattended-upgrades-stamp)))
                if [ $ELAPSEDSINCEUU -gt 86400 ]; then
                /usr/bin/unattended-upgrades
                fi
                fi




                share













                If connecting to internet with network-manager, the current default on Ubuntu, then create a dispatcher script to launch unattended-upgrades after connecting to the network:



                sudo touch /etc/NetworkManager/dispatcher.d/20-myconnectionscript
                sudo chmod +x /etc/NetworkManager/dispatcher.d/20-myconnectionscript


                In 20-myconnectionscript:



                #!/bin/sh

                if [ "$2" = "up" ];
                # only proceed if unattended-upgrades was last run more than a day ago
                ELAPSEDSINCEUU=$(($(date +%s) - $(date +%s -r /var/lib/apt/periodic/unattended-upgrades-stamp)))
                if [ $ELAPSEDSINCEUU -gt 86400 ]; then
                /usr/bin/unattended-upgrades
                fi
                fi





                share











                share


                share










                answered 2 mins ago









                SqerstetSqerstet

                183211




                183211






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • 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%2faskubuntu.com%2fquestions%2f1128433%2fhow-best-to-ensure-unattended-upgrades-runs-regularly-on-a-nomadic-laptop%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

                    Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

                    Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

                    Should I use Docker or LXD?How to cache (more) data on SSD/RAM to avoid spin up?Unable to get Windows File...