19

I've noticed (using nethogs), that /usr/lib/apt/methods/http has multiple processes, which consume ALL of my bandwidth. I want to disable the process(es).

I've tried everything: trickle, killall, etc., but nothing has worked.

How can I solve this problem?

Braiam
  • 67,791
  • 32
  • 179
  • 269

8 Answers8

7

It is because, in Ubuntu 16.04 when there are security updates available for it, it automatically downloads and install them without notifying the user.

To disable this functionality you can visit Software & Update and under Update tab, change when there are security updates to Display immediately.

enter image description here

3

apt does have (or at least, did have) configurable options for this. Run this from a terminal.

sudoedit /etc/apt/apt.conf.d/76download

And paste in the following:

Acquire
{
    Queue-mode "access";
    http
    {
        Dl-Limit "50";
    };
};

That will limit apt-get (over HTTP) to 50KB/s but just change the Dl-Limit value to whatever suits your circumstances best. Save the file and you're done.

Oli
  • 293,335
  • 2
    This is not a solution, nor does this file exist in 16.04 distribution. This only limits the speed. I want to shut it down until I do apt update. – Bhikkhu Subhuti Feb 23 '17 at 09:34
1

Probably the software updates are downloaded in the background, you can disable this feature in the settings of the Update Manager.

Adam Byrtek
  • 9,811
0

Update

Looks like you can set metered connections:

enter image description here

My bandwidth (15GB / month) was getting killed by this as well. Major usage, like 2-3 GB per day. It costs me $35USD per 5GB.

I had nothing else to lose, and was unable to determine which process was attempting to use those files. various attempts at using netstat -tup, nethogs, iptraf, lsof, etc.

hacky solution for stopping apt from downloading updates in the background

####
# could break stuff, not sure of the side effects. 
# However, it killed the process using up all my bandwidth
####
sudo mv /usr/lib/apt/methods/https /usr/lib/apt/methods/old.https
sudo mv /usr/lib/apt/methods/http /usr/lib/apt/methods/old.http
  • ubuntu 18.04

What I found was that the _apt user was the culprit, haven't found a solution to make it stop. So, still have the files renamed.

side effects

  • sudo apt-get install will fail to work, just mv the files back
jmunsch
  • 2,213
  • 1
  • 22
  • 29
  • That is really EVIL!! Especially I checked metered connection in wifi settings. – yurenchen Aug 14 '23 at 16:08
  • @yurenchen ah thanks for pointing that out, found this here, I didn't know it was slated for development when i wrote this answer ( 18.04 ). do you know offhand if it exists in the current LTS? just checked ... oh, nice! looks like it exists in 22+ – jmunsch Aug 14 '23 at 20:41
  • I have to say, with metered connection be checked on ubuntu22, it still eat bandwidths. so I say it's EVIL. and user can't disable security updates easily. – yurenchen Aug 15 '23 at 04:32
0

To find the culprit, get the PID of the /usr/lib/apt/methods/http (pick one), then use pstree with -s (show parent processes) and -p (show PIDs):

$ pstree -sp 4976
systemd(1)───apt.systemd.dai(4920)───apt.systemd.dai(4926)───apt-get(4958)───http(4976)

Then use ps to get the details of parent processes:

$ ps 4958 4926 4920
  PID TTY      STAT   TIME COMMAND
 4920 ?        Ss     0:00 /bin/sh /usr/lib/apt/apt.systemd.daily update
 4926 ?        S      0:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held update
 4958 ?        S      0:00 apt-get -qq -y update
0

finally i found a solution for this problem: this solution work fine for me

The solution:

  • Open terminal
  • Copy This Command cd /usr/lib/apt/methods and paste it into terminal and hit enter
  • Then copy this command sudo mv https https_renamed paste it into terminal and hit enter

And BOOM The Program not runing any more

What we just did:

we renamed the file 'https' so it can't run, i don't know what is the consequences. but i got no problems.

0

meet the same situation (on ubuntu 22.04),
and try to find out who's behind the scenes.

1️⃣ trys

➊ cron-apt unattended-upgrades

// check packages about automatic installation

$ apt list cron-apt unattended-upgrades

unattended-upgrades/jammy,jammy,now 2.8ubuntu1 all [installed,automatic]

// stop & disable

sudo systemctl stop unattended-upgrades.service
sudo systemctl disable unattended-upgrades.service

I'll observe for a while and give feedback

ref: https://forums.linuxmint.com/viewtopic.php?t=337534

➋ apt-daily apt-daily-upgrade

// check services

systemctl status apt-daily apt-daily-upgrade
systemctl status apt-daily.timer apt-daily-upgrade.timer

I have not try this yet.
I'll disable it if ➊ not work

➌ packagekit

https://www.linuxquestions.org/questions/debian-26/usr-lib-apt-methods-https-bandwidth-usage-4175659678/#post6033308

I have encountered this process

Ⓧ other thing

if disable auto update check,
maybe you need manually check update.

$ update-manager

2️⃣ dig

After some tries I'm a little tired,
I want to find out who's behind the scenes.

I repalce /lib/apt/methods/http with my script, to log the caller.

and I only found this (on ubuntu 22)

1. packagekitd

2023-08-17T23:23:33: ------- /usr/lib/apt/methods/https 
systemd,1 splash
  └─packagekitd,85361
      └─https,158496 /usr/lib/apt/methods/https
          ├─https,158497 /usr/lib/apt/methods/https
          │   └─pstree,158500 -alc -hps -UC age 158496
          └─tee,158498 -a /run/test/apt_https.out

I think it's packagekit.

so I stop it when I use mobile network.

systemctl stop packagekit
systemctl status packagekit

2. update-manager

when I run update-manager, I also got

2023-08-18T01:10:22: ------- /usr/lib/apt/methods/https 
systemd,1 splash
  └─systemd,2166 --user
      └─update-manager,184012 /usr/bin/update-manager --no-update --no-focus-on-map
          └─https,184791 /usr/lib/apt/methods/https
              ├─https,184792 /usr/lib/apt/methods/https
              │   └─pstree,184795 -alc -hps -UC age 184791
              └─tee,184793 -a /run/test/apt_https.out

3. apt

when I run apt update or apt install, I got

2023-08-19T01:27:29: ------- /usr/lib/apt/methods/http 
systemd,1 splash
  └─systemd,2166 --user
      └─python3,3405 /usr/bin/x-terminal-emulator
          └─bash,3426
              └─sudo,186528 apt update
                  └─sudo,186529 apt update
                      └─apt,186530 update
                          └─http,186532 /usr/lib/apt/methods/http
                              ├─http,186533 /usr/lib/apt/methods/http
                              │   └─pstree,186536 -alc -hps -UC age 186532
                              └─tee,186534 -a /run/test/apt_https.out

4. aptd

I don't remember what trigger this

2023-08-19T01:11:07: ------- /usr/lib/apt/methods/https 
systemd,1 splash
  └─aptd,184875 /usr/sbin/aptd
      └─https,184886 /usr/lib/apt/methods/https
          ├─https,184887 /usr/lib/apt/methods/https
          │   └─pstree,184890 -alc -hps -UC age 184886
          └─tee,184888 -a /run/test/apt_https.out
yurenchen
  • 441
0

If you want to kill the process simply run the following command:

sudo kill PID

Replace PID with the process ID that you can find in nethogs or top. But as you know this process is for updating Ubuntu and killing it will not upgrade your system and you should manually run sudo apt-get update and sudo apt-get dist-upgrade later on.