Prevent apt-check from eating all my memory

On Ubuntu 12.04 LTS, with server of 512MB RAM, the apt-check is using up to 250 memory and cause my system to un-usable every night, e.g.

ps ax | grep apt
14895 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14896 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14899 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14902 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14906 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14912 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14913 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14914 ?        DN     0:01 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14915 ?        DN     0:01 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14916 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14917 ?        DN     0:01 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
14920 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
15299 ?        DN     0:01 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
15302 ?        DN     0:02 /usr/bin/python /usr/lib/update-notifier/apt-check --human-readable
16368 pts/0    D+     0:00 grep apt

What the heck this script is running multiple time and eating my system resource? There is a bug here [1] which is confirmed but without any resolution. I am a little surprised that this bug is critical and exists in the LTS, sigh...

Anyway, Not sure when the ubuntu team is able to fix, Any idea how to do it by us?

[1] https://bugs.launchpad.net/ubuntu/+source/update-notifier/+bug/746508


Solution 1:

Disable update-notifier

If you want to disable update-notifier, you can follow instruction in this link.

Modified Quote from link

  1. Method 1 - Disable for one user

    Create a local(user) copy of update-notifier.desktop

    mkdir -p ~/.config/autostart
    cp /etc/xdg/autostart/update-notifier.desktop ~/.config/autostart/
    vim ~/.config/autostart/update-notifier.desktop
    

    Find this line in the local file

    X-GNOME-Autostart-Delay=60
    

    Replace with:

    X-GNOME-Autostart-enabled=false
    

    Now log out and in again, or kill the running update-notifier:

    killall update-notifier
    
  2. Method 2 - Disable for all users

    Do the same as method 1, but instead of modifying a local/user copy, modify /etc/xdg/autostart/update-notifier.desktop

Manually Check for update

After disabling update-notifier, use Update Manager(GUI), or following command line to check for package update

sudo apt-get update
sudo apt-get dist-upgrade

The first line download the latest package list from repository. The second line will show all installed packages with update available.

Solution 2:

If you're running a server install of Ubuntu with a very limited RAM configuration, I'd suggest you disable completely the automatic actions from update-notifier. You could even remove this package.

However you might still want some automatic updates to run to ensure your system gets the security fixes. One very lightweight and handy tool to do that on a server is cron-apt, it can notify you of updates through email.

Here are some instructions to install and configure it to your needs. This article on Debian Administration is also worth reading.

Solution 3:

On my Debian machines I prefer to install unattended-upgrades and anacron, then add the following lines to /etc/apt/apt.conf

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

This will run an "apt-get update", "apt-get upgrade" every day, in a fully automated way (and without any major overhead)