We are starting our Jenkins CI with the following bash command that I would like understand. Could someone explain what is doing (the only bit I get is "java -jar jenkins.war"). Thanks!
nohup java -jar jenkins.war > $HOME/jenkins.log 2>&1 < /dev/null &
The
nohup
means it will continue to run when you exit the shell.The
>
means redirect the standard output to a fileThe file it is being redirected to is
$HOME/jenkins.log
. You can find the value of$HOME
by runningecho $HOME
2>&1
means redirect standard errors to standard output, so in this example will also go into$HOME/jenkins.log
.The
< /dev/null
means read data in from/dev/null
. So if the script is expecting input it will read that instead of waiting for user input.And the
&
means run as a background task, and return you to the command line.If you want more detail, ask in the comments.
detaches the following command from the current terminal session, which prevents the process from being closed on terminal exit.
then runs the java VM with the options
which tells java to run the main class from the jar-archive jenkins.war
forwards the standard output (what usually appears in the terminal) into the given file, in this case into
$HOME/jenkins.log
means that the optput of the error channel is connected to the output of the standard output channel.
sends "nothing" as input stream to the java command.
Finally & forces the task into backgrount such that the control returns to the prompt.