I start jenkins web server using command java -jar jenkins.war
. It works great. When I close terminal the application stops.
How to make it run even if I close terminal session ?
I start jenkins web server using command java -jar jenkins.war
. It works great. When I close terminal the application stops.
How to make it run even if I close terminal session ?
The simplest and most direct method is nohup java -jar jenkins.war &
. "nohup" means "no hangup", which is vintage terminology for not ending a session when the terminal disconnects. "&" just starts the process in the background, similar to what would happen if you press CTRL+Z (and then type bg 1
) while the process is running in the foreground.
WARNING: nohup, by default, sends output of the process to a text file. If you are not careful, that file can become dangerously large in some cases. Treat it like any other ever-growing log file.
If you are frequently starting a service like Jenkins that you want to have run in the background and not close when you end your session, you should consider implementing an init script for it. Look at the scripts in /etc/init.d/ for examples. These are short shell scripts that allow you to do things like service httpd start
and service httpd stop
and even service httpd status
to find out if httpd is running, or if it's supposed to be running but isn't.
There is a great example script for the Hudson service, which functions very similarly to Jenkins (they are sibling forks of the same codebase) here: https://wiki.jenkins-ci.org/display/JENKINS/HudsonUbuntuLinuxStartupScript
append &
after your command , I mean
java -jar jenkins.war &
nohup
(or disown
the process afterward) it will be killed when the shell exits.
– Rmano
Dec 12 '13 at 16:41
sleep
and it is killed exiting the shell.
– Rmano
Dec 12 '13 at 16:57
firefox
from a console, you're running a script that later launches the firefox binary detached from your console. That step is not automatic for most commands.
– Sparr
Dec 13 '13 at 19:49