Unable to hide a running process in terminal

I yesterday upgraded by MacPorts' apps which took apparently about 4 hours. It was irritating to see the installation process going on in one tab in terminal.

Problem: to hide a running process in terminalsuch that it does not take space in my working area

I found today that there a new command coproc in Bash 4:

coprocess is executed asynchronously in a subshell, as if the command established between the executing shell and the coprocess

I am not sure whether you can use it to solve the problem or not. I did not manage to use it.

How can you hide the running process such that it is not visible in terminal but it continues to run?

Upvotes: 1

Views: 4912

Answers (3)

There is at least one thing the other repliers have not covered: how to manage hiding processes.

Suppose you have 100 background processes created with "nohup find / &". You want to quit them to really see how the background processes work. Please, use the command:

ps -ej | awk '! /grep/ && /find/ {print $2}' | xargs kill -9

Then, you may want to know how to control the keys to hide processes. You can change it to p, where susp stands for CTRL+z (^Z):

stty susp p

You can see the keys here:

stty -a

Please, compare the stdouts before and after the change. The command is particularly useful because it helps to remember other commands, such as ^W (to remove a word).

Jerome had an excellent tip about screen. I highly recommend to pursue the direction:

http://www.commandlinefu.com/commands/matching/screen/c2NyZWVu/sort-by-votes

Upvotes: 0

Jérôme
Jérôme

Reputation: 2720

Did you consider Ctrl + Z to put the process in pause, then bg to run this one in background?

To detach your process from the terminal, you can then type disown. You can now close the terminal, and even your session.

The problem here is that the outputs will appear anyway in the bash.

You can also start your program in screen. This command provide an easy way to start a program, close the console and retrieve it later.

Upvotes: 4

McBeth
McBeth

Reputation: 1207

I suspect you are looking for nohup

nohup LongRunningNoisyProgram &

will run the program, log the output to a file so you don't see it, push the program into the background, and won't cancel the program if you exit your terminal later while it is still running.

Upvotes: 2

Related Questions