LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   i need to run a shell script in background untill i kill it (https://www.linuxquestions.org/questions/linux-newbie-8/i-need-to-run-a-shell-script-in-background-untill-i-kill-it-846520/)

meabi 11-25-2010 09:38 AM

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

fordeck 11-25-2010 09:47 AM

End your command with an "&"


Regards,

Fordeck

meabi 11-25-2010 10:43 AM

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

smoker 11-25-2010 10:50 AM

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.

MTK358 11-25-2010 04:09 PM

I also wonder how to do this.

Kenhelm 11-25-2010 04:54 PM

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


All times are GMT -5. The time now is 10:20 PM.