Score:0

how to use bash to feed packages to apt a group at a time

jp flag

I need to feed apt a group of packages at a time.

I need to know how to do the following psuedo code in a bash function:

for every 5 packages in package list {
    apt install -y 5 packages ;
    sleep 10
}

Edit: the reason I need to do this is that, during setup stage, the daemon server throws an error and causes a timeout if there is more than 5 packages. this leads to most packages having broken installations. I would have to run apt install 40 times due to the large number of installs. that is why I ask this question.

pLumo avatar
in flag
To avoid downvotes, you should add more details, especially why do you need to do this. For me it seems like this is a [XY-Problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem).
hr flag
What "daemon server" exactly? Are you connecting to repositories directly, or via a proxy? What error is thrown, and what part of the operation times out?
Usermaxn avatar
jp flag
it was the freedict packages. the unpacking stage would throw an error about some server.
Score:2
in flag

use xargs

xargs -a package_list_file -n 5 apt install -y

If you need the sleep, you can use sh -c:

xargs -a package_list_file -n 5 sh -c 'apt install -y "$@"; sleep 10' xargs-sh
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.