Feedback

type to search

Running Commands in Background?

Asked by , Edited by Luis Uribe [ Admin ]

Hey… I’m doing so many works sometime, and sometimes it’s not in a way I can use tabs or different shells… Is there a way I can run some commands like upgrading in background?

NN comments
enzotib
-

Someone remove the “backport” tag, please.

harryxxx
-

Excuse me??? Where’s backport?

or Cancel

6 answers

4

rhonda [ Editor ]

What you are looking for is called job control. With ^Z (control z) you can suspend a running job, and with "bg" you then can send the process into the background. When you enter "jobs" you can see process list and their state. To bring one of the processes in the background into the foreground again (because maybe it waits for user input or such) you can do "fg x" where you replace x with the number of the job (written in square brackets before the command name).

To start a job directly in the background you can add a & at the end. As an upgrade process usually wants confirmation the ^Z and bg approach is better suited than starting it right off with &.

And yes, screen is really worth exploring, you should get used to it, especially when you work on remote servers and might lose network in the middle of a build process or similar. 

NN comments
goacid
-

I agree, screen is always the best solution for daily admin task (no background task).

or Cancel
0

amlj [ Editor ]

Just add ‘&’ at the end… Like:

# aptitude dist-upgrade &

Now, the command is running in the background… But remember, it has a lower priority than normal processes.

You can get it back to foreground, if you enter: fg

Hope that helps.

NN comments
amlj
-

Hey, can someone tell me what’s wrong with this solution? I’m just interested to know… As some seem to not read the replies… Maybe I’m wrong… You can add a comment and tell me what’s wrong..

I’d appreciate it.

linulin
-
Your solution does not play well with interactive programs like aptitude. Also, your note about lower priority is nonsense.

amlj
-
I don’t think that it’s nonsense… Also, screen is not installed by default… And if you have ever used something other than your home-computer, you’d understand that it’s better to have a minimal system, and work with packages which are installed by default… Screen is not in a min install.

harryxxx
-

It’s OK guys… Thank you all… I’ll try out all of ‘em… But I think all the solutions are good. AMLJ’s solutions are usually 'Debianish’ as he says!! xD So he just likes to use tools which are not installed on a minimal installation as little as possible… Screen seems like a great solution too, I mean, from what I see it’s also good. I’ll try all solutions out! Thanks a lot!

amlj
-
I’ve found two exceptions so far: 1) less 2) vim Those are the only things I install, even if they are not in the minimal installation. Also, solutions are different… Using this method will work, and I don’t see anything wrong with it. Neither do I see anything wrong with using screen… Also, I simply give solutions the way I think is better… You do the same… In fact, we all do this. If I don’t like a solution, it doesn’t mean it’s wrong/bad/stupid/useless/etc.

rhonda
-
How does the “not installed by default” play into the picture of you always telling people the “vim” way to do things? It’s neither in min install?

or Cancel
0

rexens

Through this article we can follow the above article to acknowledge the running commands in background and the detail of this command you like to posted here. Actually, I try to get a site to place order essay online but i’m glad to know about this command. I was looking this command and now i got it.

or Cancel
0

akshay14184

you are looking for is called job control. With ^Z (control z) you can suspend a running job, and with “bg” you then can send the process into the background Looking Running Bring When you enter “jobs” you can see process list and their state. To bring one of the processes in the background into the foreground again (because maybe it waits for user input or such) you can do “fg x” where you replace x with the number of the job (written in square brackets before the command name).

or Cancel

Your answer

You need to join Debian to complete this action, click here to do so.