2

hi everything is in the title,

i want to Suspend temporarily linux update apt for the session until reboot

reason? when i'm on my mobile phone hotspot i don't want to linux PC to DL GB of data

so i just need a command (non root if possible) saying something like: "apt -stop_auto_update" or at worse a way to "kill apt-auto-update-daemon"

alex
  • 23
  • Does it have to be command line? Can change the way updates are handled from software update GUI. Daily, weekly, or never. Just remember to remind yourself to change back after. – crip659 Oct 02 '19 at 11:16
  • mandatory CLI yes because this goes in a script detecting which network the laptop PC is on... – alex Oct 03 '19 at 16:32

1 Answers1

1

You can run a command based on this answer:

Create a script:

#!/bin/bash

systemctl stop apt-daily.service
systemctl kill --kill-who=all apt-daily.service

# wait until `apt-get updated` has been killed
while ! (systemctl list-units --all apt-daily.service | egrep -q '(dead|failed)')
do
  sleep 1;
done

# now proceed
echo Apt Daily Service has been killed

Mark the script as executable in order to call the command:

sudo chmod /path/to/my_script.sh

You need sudo powers to call the command:

sudo /path/to/my_script.sh

When you are away from the hotspot and back to your regular network reboot to reinstate apt services or type:

sudo systemctl start apt-daily.service

Of course you can forgo the fancy script altogether and stop services with:

sudo systemctl stop apt-daily.service
  • thanks for that script / cmd, that's almost it, the cmd will go strait into a startup script, only pb left is that root "sudo" required to shutdown apt... i'm pretty sure the startup script goes as a user no a root... – alex Oct 03 '19 at 16:37
  • Call the script in /etc/rc.local and ensure rc.local service is enabled. I'm on phone so can't be positive on spelling... – WinEunuuchs2Unix Oct 03 '19 at 17:11
  • Also I saw comment above you may have to wait about 1 minute until a network is connected... – WinEunuuchs2Unix Oct 03 '19 at 17:13
  • yes there is something like that in https://askubuntu.com/questions/290099/how-to-run-a-script-during-boot-as-root also another dirty workaround is to "echo password | sudo -S cmd" but the root password is in clear... anyway thanks a lot @WinEunuuchs2Unix – alex Oct 03 '19 at 20:55