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

link|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 at 1:10
@Zoredache what tools would you recommend? – DD. Feb 7 at 9:10
feedback

1 Answer

up vote 0 down vote accepted

Because nohup automagically redirects output to nohup.out.

link|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 at 23:56
the shell is producing that output to let you know of the backgrounded processes id. – mdpc Feb 7 at 0:07
yes my whole point is why do I not see that when I run start_java.sh? – DD. Feb 7 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 at 0:14
How do I get my script to print stderr so that I can see any errors? – DD. Feb 7 at 0:17
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

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