18

I am starting my application in the background using nohup as mentioned below -

root@phx5qa01c:/bezook# nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file --fsconfigdir /opt/exhibitor/conf --hostname phx5qa01c.phx.qa.host.com > exhibitor.out &
[1] 30781
root@phx5qa01c:/bezook# nohup: ignoring input and redirecting stderr to stdout

But every time I see this message -

nohup: ignoring input and redirecting stderr to stdout

Will there be any problem if I see this message? What does it mean and how can I avoid it?

  • 2
    have you tried : nohup java -jar blaa bla >/tmp/test.out 2>&1 & – Rahul Patil Dec 19 '13 at 8:03
  • instead of using /tmp/test.out can I use exhibitor.out. Sorry for asking dumb question as I am pretty new to these things.. – arsenal Dec 19 '13 at 8:05
  • yes.. you can use.. that's just std error/output file. but what is status after adding 2>&1 ? – Rahul Patil Dec 19 '13 at 8:12
19

To make sure that your application is disassociated from its terminal - so that it will not interfere with foreground commands and will continue to run after you logout - nohup ensures that neither stdin nor stdout nor stderr are a terminal-like device. The documentation describes what actions it takes:

If the standard output is a terminal, all output written by the named utility to its standard output shall be appended to the end of the file nohup.out in the current directory. If nohup.out cannot be created or opened for appending, the output shall be appended to the end of the file nohup.out in the directory specified by the HOME environment variable. If neither file can be created or opened for appending, utility shall not be invoked.

If the standard error is a terminal, all output written by the named utility to its standard error shall be redirected to the same file descriptor as the standard output.

You redirected stdout to a file when you typed > exhibitor.out in your command line. If you're OK with having your application's stderr be directed to the same file as its stdout, you don't need to do anything else. Or you can redirect stderr to a different file by adding an argument such as 2> exhibitor.err. (Thanks to an unknown user - my notifications didn't show a name - for suggesting inclusion of this alternative.)

  • 2
    It's also useful to close the input fd manually like so: </dev/null; Linux will do this automatically, but if not done manually you will still get a line in nohup's output that reads: nohup: ignoring input – wulfgarpro May 10 '17 at 1:14
15

You can get rid off the message if you redirect std error to std output:

nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file --fsconfigdir /opt/exhibitor/conf --hostname phx5qa01c.phx.qa.host.com > exhibitor.out 2>&1 &
3

In my situation, I redirect stdout and stderr, but it also displays following in the log file:

nohup: ignoring input

To remove that warning, you have to also redirect stdin as follows:

nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file --fsconfigdir /opt/exhibitor/conf --hostname phx5qa01c.phx.qa.host.com > exhibitor.out 2>&1  </dev/null &

I kown this answer is definitely late for you, but maybe it would help others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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