Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: "-y" not working in apt-get autoremove script

  1. #1
    Join Date
    Feb 2016
    Beans
    Hidden!

    "-y" not working in apt-get autoremove script

    I have this line in a script that runs with sudo:

    Code:
    aptitude update && sudo aptitude -y upgrade && sudo apt-get -y autoremove
    However when it comes time to do the autoremove it waits for me to press <Enter> or <Y> instead of doing a force yes like the command says to.

    If I run
    Code:
    sudo apt-get -y autoremove
    ...on its own, it proceeds without user input like it should. Just not in my script for some reason.

    I tried creating a new .sh file (with chmod +x) to call from the one where its not running properly- calling it like so:

    Code:
    sudo konsole -e "~/Scripts/AptitudeAutoremove.sh"
    But this doesn't work at all.

  2. #2
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,520

    Re: "-y" not working in apt-get autoremove script

    unattended-upgrades will do all that (including autoremove). Do you have it installed?

  3. #3
    Join Date
    Feb 2016
    Beans
    Hidden!

    Re: "-y" not working in apt-get autoremove script

    Quote Originally Posted by ian-weisser View Post
    unattended-upgrades will do all that (including autoremove). Do you have it installed?

    Yes, but I've never got it working right.

    This is my /etc/apt/apt.conf.d/50unattended-upgrades (I think it's right):

    Code:
    // Automatically upgrade packages from these (origin:archive) pairs
    Unattended-Upgrade::Allowed-Origins {
            "${distro_id}:${distro_codename}";
            "${distro_id}:${distro_codename}-security";
            // Extended Security Maintenance; doesn't necessarily exist for
            // every release and this system may not have it installed, but if
            // available, the policy for updates is such that unattended-upgrades
            // should also install from here by default.
            "${distro_id}ESM:${distro_codename}";
            "${distro_id}:${distro_codename}-updates";
            "${distro_id}:${distro_codename}-proposed";
            "${distro_id}:${distro_codename}-backports";
    };
    
    // List of packages to not update (regexp are supported)
    Unattended-Upgrade::Package-Blacklist {
    //      "vim";
    //      "libc6";
    //      "libc6-dev";
    //      "libc6-i686";
            "thunderbird";
            "thunderbird-locale-en"
    
    };
    
    // This option allows you to control if on a unclean dpkg exit
    // unattended-upgrades will automatically run
    //   dpkg --force-confold --configure -a
    // The default is true, to ensure updates keep getting installed
    //Unattended-Upgrade::AutoFixInterruptedDpkg "false";
    
    // Split the upgrade into the smallest possible chunks so that
    // they can be interrupted with SIGUSR1. This makes the upgrade
    // a bit slower but it has the benefit that shutdown while a upgrade
    // is running is possible (with a small delay)
    Unattended-Upgrade::MinimalSteps "true";
    
    // Install all unattended-upgrades when the machine is shuting down
    // instead of doing it in the background while the machine is running
    // This will (obviously) make shutdown slower
    //Unattended-Upgrade::InstallOnShutdown "true";
    
    // Send email to this address for problems or packages upgrades
    // If empty or unset then no email is sent, make sure that you
    // have a working mail setup on your system. A package that provides
    // 'mailx' must be installed. E.g. "user@example.com"
    //Unattended-Upgrade::Mail "root";
    
    // Set this value to "true" to get emails only on errors. Default
    // is to always send a mail if Unattended-Upgrade::Mail is set
    //Unattended-Upgrade::MailOnlyOnError "true";
    
    // Do automatic removal of new unused dependencies after the upgrade
    // (equivalent to apt-get autoremove)
    Unattended-Upgrade::Remove-Unused-Dependencies "true";
    
    // Automatically reboot *WITHOUT CONFIRMATION*
    //  if the file /var/run/reboot-required is found after the upgrade
    Unattended-Upgrade::Automatic-Reboot "false";
    
    // If automatic reboot is enabled and needed, reboot at the specific
    // time instead of immediately
    //  Default: "now"
    //Unattended-Upgrade::Automatic-Reboot-Time "02:00";
    
    // Use apt bandwidth limit feature, this example limits the download
    // speed to 70kb/sec
    //Acquire::http::Dl-Limit "70";
    

  4. #4
    Join Date
    Feb 2016
    Beans
    Hidden!

    Re: "-y" not working in apt-get autoremove script

    bump

  5. #5
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,520

    Re: "-y" not working in apt-get autoremove script

    I recommend against enabling automatic updates from -proposed. Down that path lies breakage.
    Other than that, the config looks fine.

    Are you saying that automatic updates have some problem? Or are not running?
    What is the problem you are having?

  6. #6
    Join Date
    Feb 2016
    Beans
    Hidden!

    Re: "-y" not working in apt-get autoremove script

    Quote Originally Posted by ian-weisser View Post
    Are you saying that automatic updates have some problem? Or are not running?
    Exactly. Current state has no effect. I suspect something about cron not being set right. Seem to remember readibg something about enabling some sort of 'daily' preset file but am not sure.

  7. #7
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,520

    Re: "-y" not working in apt-get autoremove script

    Please show us the complete output of the following:
    Code:
    ls -l /var/lib/apt/periodic/
    systemctl list-timers | grep apt
    The first lists the timestamps of many apt actions, a handy tool to see when unattended-upgrade last ran.
    The second lists today's scheduled run time for unattended-upgrade.

  8. #8
    Join Date
    Feb 2016
    Beans
    Hidden!

    Re: "-y" not working in apt-get autoremove script

    Quote Originally Posted by ian-weisser View Post
    Please show us the complete output of the following:
    Code:
    ls -l /var/lib/apt/periodic/

    Code:
    -rw-r--r-- 1 root root 0 Jan  3 08:53 autoclean-stamp
    -rw-r--r-- 1 root root 0 Jan  4 18:00 download-upgradeable-stamp
    -rw-r--r-- 1 root root 0 Jan  4 18:00 unattended-upgrades-stamp
    -rw-r--r-- 1 root root 0 Jan  4 18:00 update-stamp
    -rw-r--r-- 1 root root 0 Jan  4 21:20 update-success-stamp
    -rw-r--r-- 1 root root 0 Jan  4 18:00 upgrade-stamp
    Quote Originally Posted by ian-weisser View Post
    Code:
    systemctl list-timers | grep apt

    Code:
    Fri 2018-01-05 06:35:21 EST  9h left     Thu 2018-01-04 18:00:37 EST  3h 22min ago apt-daily-upgrade.timer      apt-daily-upgrade.service
    Fri 2018-01-05 14:28:41 EST  17h left    Thu 2018-01-04 18:00:37 EST  3h 22min ago apt-daily.timer              apt-daily.service

  9. #9
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,520

    Re: "-y" not working in apt-get autoremove script

    Unattended Upgrades is installed, running, and successfully completing it's runs.

    Here's how we know that:
    -rw-r--r-- 1 root root 0 Jan 4 18:00 unattended-upgrades-stamp
    The stamp only places upon successful completion.

    Next step, please show us the contents of /var/log/unattended-upgrades/unattended-upgrades.log
    Edit the output so it contains output only from Jan 4.
    Last edited by ian-weisser; January 5th, 2018 at 07:07 PM.

  10. #10
    Join Date
    Feb 2016
    Beans
    Hidden!

    Re: "-y" not working in apt-get autoremove script

    Quote Originally Posted by ian-weisser View Post
    Unattended Upgrades is installed, running, and successfully completing it's runs.

    Here's how we know that:

    The stamp only places upon successful completion.

    Next step, please show us the contents of /var/log/unattended-upgrades/unattended-upgrades.log
    Edit the output so it contains output only from Jan 4.

    Unfortunately the only content is from today it seems:

    Code:
    2018-01-05 06:35:34,189 INFO Initial blacklisted packages: thunderbird thunderbird-locale-en
    2018-01-05 06:35:34,189 INFO Initial whitelisted packages:  
    2018-01-05 06:35:34,190 INFO Starting unattended upgrades script
    2018-01-05 06:35:34,190 INFO Allowed origins are: ['o=Ubuntu,a=xenial', 'o=Ubuntu,a=xenial-security', 'o=UbuntuESM,a=xenial', 'o=Ubuntu,a=xenial-updat
    es', 'o=Ubuntu,a=xenial-proposed', 'o=Ubuntu,a=xenial-backports']
    2018-01-05 06:35:37,929 INFO No packages found that can be upgraded unattended and no pending auto-removals
    I tend to not leave it on...

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •