I have a heavy application running on jboss-7.1.1 on linux server. I came across this command to start the jboss “nohup ./standalone.sh -b 0.0.0.0 &“. But i want to understand more about this command line. Also the nohup.out file size keeps on increasing day by day. Is it due to the command line that i executed to start the jboss. Is there any way to avoid nohup.out to get created.
Advertisement
Answer
nohup
nohup
makes the following command immune to the SIGHUP signal. It detaches the command from the terminal. When a terminal is closed, any process (or commands) running in the terminal are sent the SIGHUP (hang-up) signal and then die.
This means that if the terminal screen is closed (the terminal from where ./standalone.sh is started), standalone.sh
remains running. It is detached from it’s terminal.
Foreground and background
The &
at the end of the command puts the standalone.sh
program in the background. Background means that the command does not block the terminal shell. A command in the foreground on the other hand will block any input to the terminal shell until it has completed.
An example: read -p "enter name "
expects input from the user. It blocks the terminal shell until ENTER is keyed. The read
command is in the foreground and blocks the terminal from receiving further commands. A background process does not block the shell that started it.
nohup.out
This file contains the output from the command issued using nohup
. In your case it is the output from the standalone.sh script.
You can direct the output from a command to a file:
nohup ./standalone.sh -b 0 0 0 0 & > myfile.txt
Or even dispose of the output by writing to /dev/null
. If you do this you will lose any errors generated by the command.
nohup ./standalone.sh -b 0 0 0 0 & > /dev/null
If you want to preserve any error messages, but want to ignore any other output, then redirect the error stream (stream 2) thus:
nohup ./standalone.sh -b 0.0.0.0 & >/dev/null 2>my-error-file.txt"