Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Suppose I install a package on a debian based system via sudo aptitude install mypackage. Suppose the package is big and it takes long to download and install it.

When I notice that I want to install another package after invoking that command I have to wait until the first package is completely installed.

Is it possible to make aptitude to start automatically installing the second package, after the first one is finished?

share|improve this question
    
Along with the good answer below, you could always write a basic script. –  nicodemus13 Nov 9 '12 at 20:26
add comment

1 Answer

up vote 4 down vote accepted

You can list multiple packages to install at once:

aptitude install package1 package2

If you truly care about the order in which they are installed (you almost definitely don't, as aptitude takes into account dependencies and other subtleties automatically), or are looking for a more general solution, do something like the following:

aptitude install package1 && aptitude install package2

The logical AND (&&) operator will only perform the second command if the one preceding it succeeded (returned exit status 0).

If you are asking how to do this even after you initially did the command, try this another terminal:

aptitude-after() {
    printf '%s\n' "Waiting for current aptitude operations to finish"
    while pgrep -x aptitude >/dev/null 2>&1; do
        sleep 10
    done
    printf '%s\n' "Done, running new instance of aptitude."
    aptitude "$@"
}

Run it as aptitude-after install mypackage2. It will wait for all current instances of aptitude to finish.

share|improve this answer
    
Yes, that's clear. My problem is how to do it, when the install process of the first package is already running. Then I could wait until it is finished and start the installation of the second package. But is there a way to make aptitude install the package automatically after the first one is finished? –  student Nov 9 '12 at 17:06
1  
@student Ah, okay. I updated my answer. –  Chris Down Nov 9 '12 at 17:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.