Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I setup my start_java.sh script as follows:

#!/bin/sh
echo "starting process"
nohup java XXX

When I run:

[root@box ~]# bash start_java.sh

it prints

starting process

However if I run

nohup java XXX

It prints:

[1] 19852

Why do I not see this when I run the bash script? I want to see

starting process

[1] 19852

share|improve this question
    
If you are trying to build a startup script for some kind of daemon, you might be better off using one of the tools built for this purpose. –  Zoredache Feb 7 '12 at 1:10
    
@Zoredache what tools would you recommend? –  DD. Feb 7 '12 at 9:10
add comment

1 Answer

up vote 0 down vote accepted

Because nohup automagically redirects output to nohup.out.

share|improve this answer
    
So when I run it from the command line why does it output "[1] 19852"...but not when I run it from the script? –  DD. Feb 6 '12 at 23:56
    
the shell is producing that output to let you know of the backgrounded processes id. –  mdpc Feb 7 '12 at 0:07
    
yes my whole point is why do I not see that when I run start_java.sh? –  DD. Feb 7 '12 at 0:11
    
the output [1]... is sent to stderr which has not been captured to a file thus you lose it. –  mdpc Feb 7 '12 at 0:14
    
How do I get my script to print stderr so that I can see any errors? –  DD. Feb 7 '12 at 0:17
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.