LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   launching a task from cli and "divorcing it from terminal task (https://www.linuxquestions.org/questions/linux-general-1/launching-a-task-from-cli-and-divorcing-it-from-terminal-task-861865/)

wufo 02-10-2011 11:21 AM

launching a task from cli and "divorcing it from terminal task
 
How do you launch a task from a terminal command line interface and it not be kill'ed if you close the terminal window.

Like if I run jedit I type
jedit &
which launches jedit as a backgorund task. But, if I close terminal window, jedit dies to. How do I laucnch jedit and completely divorce it from the terminal task?

tj

MTK358 02-10-2011 11:39 AM

use nohup

Like this:

Code:

nohup jedit &
The '&' is only necessary if you want to continue using the terminal afterwards.

David the H. 02-10-2011 12:00 PM

Bash also has a disown builtin command that lets you detach a process after you've launched it. ctrl+z to pause the process, then run bg to send it to the background, and finally run disown, and it will be "forgotten" by the shell.

If you want to be able to detach a process and re-attach to it later, consider using screen.

MTK358 02-10-2011 01:14 PM

I didn't know about the disown command.

wufo 02-11-2011 09:07 AM

Thanks to both of you.

nohup worked as suggested with jedit.
Had to try another app to disown since jedit automatically placed itself in background. But, worked as stated on another app.

Thanks again

tj

MTK358 02-11-2011 09:13 AM

Mark the thread as solved.

David the H. 02-11-2011 11:32 AM

You can get a list of all background processes running in a shell with the jobs command. Then you can address any of those jobs with disown %n, "n" being the number of the job you want. Or use disown -a to detach all of them.

Check out help disown or the SHELL BUILTIN COMMANDS section of the bash man page, and read up on job control.


All times are GMT -5. The time now is 04:31 PM.