Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I setup my script as follows:

echo "starting process"
nohup java XXX

When I run:

[root@box ~]# bash

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
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 – 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

Your Answer


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.