LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 02-22-2011, 06:28 PM   #1
raulab
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Rep: Reputation: 0
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?
 
Old 02-22-2011, 06:46 PM   #2
marco18
Member
 
Registered: Jul 2007
Location: Argentina
Distribution: Ubuntu 13.04 , Debian Lenny 5.0.7
Posts: 223

Rep: Reputation: 21
What does startServer.sh does exactly?
 
Old 02-22-2011, 08:12 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,246

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
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
 
Old 02-23-2011, 12:37 PM   #4
raulab
LQ Newbie
 
Registered: Feb 2011
Posts: 8

Original Poster
Rep: Reputation: 0
thanks that anaswered my question. One quesiton about this. what is the symbol > here?
 
Old 02-23-2011, 07:47 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,246

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


Reply

Tags
nohup, shell script


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
A question about shell (bash shell) thomas2004ch Linux - Newbie 4 08-27-2009 02:09 AM
nohup sycamorex Linux - General 4 01-08-2008 05:49 PM
problem with nohup command and nohup file size vbseeker Linux - General 1 09-17-2006 11:36 AM
help on nohup vinayuh Linux - General 3 07-22-2005 12:24 PM
Shell script using nohup hangs lloracle_dba Programming 7 05-04-2005 10:52 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration