LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   question about nohup in shell (http://www.linuxquestions.org/questions/linux-newbie-8/question-about-nohup-in-shell-864398/)

raulab 02-22-2011 06:28 PM

question about nohup in shell
 
Hi I have a starServer.sh command in a shell script along with a bunch of command.

Th startServer.sh command prints out stuff on stdout and stays printing since the server is up.

However eve though I want to start the server I want it to continue executing the commands after ./startServer.sh in the same flow.

How can I achieve it?

marco18 02-22-2011 06:46 PM

What does startServer.sh does exactly?

chrism01 02-22-2011 08:12 PM

I think what you want is '&' ie to background the task, which enables the rest of the script to continue. However if it's outputting to stdout, you should capture that.
nohup is used to allow a cmd issued from the cmd line to continue after you logout. Putting it all together looks like this
Code:

nohup myprog.sh >myprog.log 2>&1 &
NB: these 3 i/o channels are automatically assigned to every process
sdtin = 0
stdout = 1
stderr = 2

raulab 02-23-2011 12:37 PM

thanks that anaswered my question. One quesiton about this. what is the symbol > here?

chrism01 02-23-2011 07:47 PM

> = redirect output to specified channel
>> = append output to specified channel

If you use the first, it will always overwrite any same named file at each new invocation. OTOH, if you don't want append (ie one file for all invocations), embed the current date in the target output filename.
Note also that you can send stdout & stderr to different files, but matching the contents up afterwards is a PITA. I rarely split them...


All times are GMT -5. The time now is 06:18 PM.