I am running long program on server, which is basically Jar file of java program. I want to keep this program running even if SSH terminal is closed, how I can keep this program running on server?
Two different ways:
nohup- by starting the program with
nohup /path/to/program &, nohup keep the program running and any output will be redirected to the file
nohup.outin the current directory
tmuxif either of them is installed on the server. They are a way to keep one or more shells going so that you can re-attach to them the next time you login - it's a much more powerful utility than nohup.
man tmuxfor more information.
Here's how to keep a process running that you've already started without using nohup.
Suppose you started decompressing a large archive and now you want to go home.
$ tar -xzf bigfile.tar.gz
Press ctrl-z to send the processs to the background. You can type "jobs" and press enter and see the job number for your process, probably it's 1.
$ disown %1
Either screen or tmux will both work.
See for instance http://www.jeffstory.org/wordpress/?p=132 for a quick tutorial on how to use it.
While I've never used Apache Daemon, it may do what you want. It will run your Java program as a daemon, as a process in the background.
I'd then use htop to monitor this process, and shut it off if it takes up too many resources.
You will need to install htop apt-get:
sudo apt-get install htop
Then run via
When you see your process, you can kill it by selecting it in the list (via the arrow keys) and then kill it by pressing