I have an Ubuntu 14.04 server and I am trying to start Apache Karaf from a ssh, exit the ssh and expect Karaf to remain execting. What I actually find is that as soon as the last ssh is closed/logged out, the Karaf process is terminated.
I start Karaf with the bin/start command as described here (background mode) and the docs state that this should put Karaf into the background mode, however my experience has shown this does not happen. As soon as I logout of ssh, the process dies.
I have tried using ‘nohup’ but again the karaf process is always killed once the last ssh is closed. I don’t believe this is a problem with Karaf but some configuration of Ubuntu. I also see the same behaviour on Linux Mint.
However, Karaf DOES run as a backgorund process if I run it on a RaspberryPi, which is running Raspbian.
Is there a configuration of sshd that forces all processes started in a ssh to terminated once ALL ssh connections are ended? Whatever I try I cannot make a background process remain once I have logged out.
Looking at the
startscript it uses
exec "$KARAF_HOME"/bin/karaf server "$@" >> "$KARAF_REDIRECT" 2>&1 &
and thus another process is created. If I just do a
bin/startfile descriptors 0,1 and 2 are all directed toward `/dev/null’.
If I do
nohup ./start 0<&- &>/dev/null &followed by a
disown, then fd 0,1,2 of the resultant process all go to
/dev/null. I noted on the RaspberryPi that fd 0,1 and 2 all state
The process might be running under the session leader, in this case the shell, once you exit the shell, all the processes under it are killed. Here are the steps you might need to follow to
disown the process –
The first two steps are just for confirmation –
jobsto see the process. If it has actually been backgrounded, it should be listed here.
fgbring it to foreground – you might need to supply the job id if there are multiple jobs in backgrouund.
ctrl+Z– stop process.
bg– background it
disown -h [id]– replace id with the job id.
Second option – daemonize the process
nohup ./scriptname 0<&- &>/dev/null &
Source : Link , Question Author : D-Dᴙum , Answer Author : Daniel t.