Fancy stuff about my technical life
What this all about is....detach & reatach running processes from/to a terminal
posted by cimnine @ 7:47pm, Friday 23 January 2009.
I just got introduced to some nice linux/unix-terminal commands.If you run a process, you can STOP it (this is different to KILL!) by pressing CTRL-Z.
Now the process is STOPPED, which means, it is suspended.
You now have two options:
- Enter "bg" to BACKGROUND the process.
This means, the process will RUN again, but in the background. - Enter "fg" to FOREGROUND the process.
This means, the process will RUN again, just as it ran before.
If you used "bg" before, you have now the option to permanently detach the process form the console. (You can exit the console, and the process will continue doing what he does.) Well, the command is rather simple. Just enter "disown %1".
IMPORTANT: Use this only, if you bg'ed the process before. Otherwise you have an paused process somewhere in the background, which maybe blocks files or memory.
An addition:
If you detach a second process, you'll have to specify, which process you want to bg or fg. You can do that by its identifier. This is a % followed by the number in the bracket you saw after you hitted CTRL+Z. Note: If you want to disown a second process, use the just described identifier instead of "%1", which is shown above. (This "%1" in fact IS such a process identifier. It identifies the first detached process.)
Another addition:
I don't know if this procedure works with other shells than bash.
Hope this wasn't too confusing now and I could help someone.
~Chris
PS: An alternative would be to use GNU screen.
Comments
Submit Your Comment
You are not logged in.