LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-25-2010, 10:38 AM   #1
meabi
LQ Newbie
 
Registered: Nov 2010
Location: INDIA
Distribution: FEDORA
Posts: 25

Rep: Reputation: 9
i need to run a shell script in background untill i kill it


how to run a run a shell script in background even if i exit the terminal or logout,

the process end only when i kill with command kill
 
Old 11-25-2010, 10:47 AM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
End your command with an "&"


Regards,

Fordeck
 
Old 11-25-2010, 11:43 AM   #3
meabi
LQ Newbie
 
Registered: Nov 2010
Location: INDIA
Distribution: FEDORA
Posts: 25

Original Poster
Rep: Reputation: 9
but with a single & it got scope only for current terminal

my need is to execute the command up to when i kill it using kill command
 
Old 11-25-2010, 11:50 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
use screen.

man screen

try this ...

open a terminal and type screen

The title bar will change to read [screen 0: bash]
type Ctrl + A then c
the title bar will change to read [screen 1: bash]
run ls -Rl /

when that is running type Ctrl + A then 0 (zero)
You will change back to the screen 0 window
Now type Ctrl + A then d
You will detach from the screen session and the title bar will return to normal.

You can shut the terminal now and log out, but not shut down, obviously.
When you open a new terminal, type screen -r and you go back to the session you started earlier.
To kill screen, just type exit until you have closed all the screen sessions.

Last edited by smoker; 11-25-2010 at 11:59 AM.
 
Old 11-25-2010, 05:09 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I also wonder how to do this.
 
Old 11-25-2010, 05:54 PM   #6
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 336

Rep: Reputation: 141Reputation: 141
Try
nohup command &
http://linux.101hacks.com/unix/nohup-command/
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Shell script to kill an on going program? cruiz_bugs Programming 5 08-04-2009 09:41 AM
What is the easiest way to run a shell script in the background on 10 servers? abefroman Linux - Software 3 03-12-2008 10:24 AM
How to run a shell script in a background? anandv_1234 Linux - Newbie 3 12-23-2007 04:03 AM
how do i get a shell script to run in the background? tjyorkshire Programming 4 07-06-2007 03:28 AM
kill the process invoked from a shell script, when the script is killed kskkumar Linux - Software 8 05-23-2007 12:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:22 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration