Ubuntu – Help: “aptd” is maxing out the CPU

12.04aptdpkg

I am running Ubuntu 12.04 and have a "aptd" process running as root (which I understand is correct) but eating 95% CPU (which is definitely not right).

As per one of the answers here How to stop "aptd" from maxing out my CPU? I tried to run dpkg-reconfigure which just added a new process eating 20% CPU for ages until it reported

  /usr/sbin/dpkg-reconfigure: menu is broken or not fully installed.

Possibly related the upgrade process recently left a huge apt.log file without getting to the end: A huge apt log file from failed upgrade – what went wrong & how do I fix it?

What do I need do to get my system back into normal operation?

UPDATE #1

This bug report https://bugs.launchpad.net/ubuntu/+source/apt/+bug/665580 suggests I run

 sudo apt-get -y update

But it says

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/

So I tried

sudo rm /var/lib/apt/lists/lock
sudo apt-get -y update

This has not stopped aptd from maxing the CPU.

Despite warnings not to I have tried to kill the process and it refuses to be killed.

Update #2

This is now slowly cooking my CPU and the fans are on full speed all of the time. Man they are loud (must do something about that next hardware upgrade).

aptd is running with the command line /usr/bin/python /usr/bin/aptd and apparent has used 1d17h CPU Time.

However it has now been joined by apt-get which is running under the command line apt-get -qq -y -d -dist-upgrade. As a result aptd has "dropped" to 85.1MiB Memory with 183.8MiB Virtual Memory used up.

I am looking at restarting or shutting down, if only to save my hardware from cooking.

Update #3

As per ShadowMitia's comments I tried

sudo killall -9 apt-get
sudo kill -9 _pid_ 

Which killed the naughty processes. Now to figure out what was broken and fix that?

I am going to try restarting to see if it happens again.

Update #4

Okay, so I just restarted.

apt-check got in there right away and shot to about 88% aptd then joined in and climbed rapidly to 100% to 102%.

apt-check is still there but at 40% to 50%.

Looks like I will need to kill those off sooner or later?

Update 5

Apt-check and aptd were still burning away after over 24 hours of CPU time. I killed them off again. Will try upgrading and report back.

Best Answer

From what I could find here and here you have to do the following steps:

  1. Kill apt-get and aptd process. Use killall -9 pid (where pid is the process id which you can find by running top). -9 is required to make sure the process is terminated.

  2. Then you need to try

sudo dpkg-reconfigure -phigh -a and sudo dpkg --configure -a

  1. (optional) If all of the above steps work on their own then you should be fine but I would recommend you update to a more recent version of ubuntu, because it appears it was a bug in the way apt-get worked and should've been removed completly in a more recent release. Maybe a simple apt-get update && apt-get upgrade is sufficient (and would be quite ironic!).
Related Question