0

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

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

1 Answer 1

0

Because nohup automagically redirects output to nohup.out.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .