LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-10-2011, 11:21 AM   #1
wufo
Member
 
Registered: Oct 2004
Posts: 209

Rep: Reputation: 15
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
 
Old 02-10-2011, 11:39 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
use nohup

Like this:

Code:
nohup jedit &
The '&' is only necessary if you want to continue using the terminal afterwards.
 
Old 02-10-2011, 12:00 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
1 members found this post helpful.
Old 02-10-2011, 01:14 PM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I didn't know about the disown command.
 
Old 02-11-2011, 09:07 AM   #5
wufo
Member
 
Registered: Oct 2004
Posts: 209

Original Poster
Rep: Reputation: 15
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
 
Old 02-11-2011, 09:13 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Mark the thread as solved.
 
Old 02-11-2011, 11:32 AM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.

Last edited by David the H.; 02-11-2011 at 11:42 AM. Reason: 1. minor correction 2. re-link to up-to-date page
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel panic attempted to kill the idle task! in idle task - not syncing dudutworld Linux - Newbie 2 09-16-2013 01:50 PM
LXer: Task warrior, the cli organizer LXer Syndicated Linux News 0 12-11-2010 02:30 PM
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 09:39 AM
Terminal window closes when task completes JohnKFT Slackware 2 12-20-2004 11:07 PM
ewbie questions CLI & task manager :) wogga Linux - Software 3 05-24-2004 04:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration