Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by slm, jasonwryan, Renan, Patrick, Anthon May 26 at 3:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

Two different ways:

  1. Use 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.out in the current directory
  2. Use screen or tmux if 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 screen or man tmux for more information.
share|improve this answer
    
+1 for tmux. It works brilliantly. –  jaredad7 May 25 at 13:26

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.

share|improve this answer

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.

Then do:

$ disown %1
share|improve this answer

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

htop

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

f9, k 
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.