LewisMc
LewisMc

Reputation: 349

Java Jar running on remote ubuntu server

I'm running a service on a remote server using a packaged jar, the problem is when I end the ssh session it also kills the process' including the service I need.

I played with this a year or so ago with a cron script but had no luck, any pointers would be appreciated.

Lewis

Upvotes: 1

Views: 1352

Answers (3)

3urdoch
3urdoch

Reputation: 7332

You need to use the nohup command, this prevent the process from being hung up when the session ends.

nohup java -jar myjar.jar

Just thought I would add this, in reponse to to what Marvin Pinto said. You can also send the console output to a file like so:

nohup java -jar myjar.jar >> logfile.log 2>&1

Upvotes: 5

Marvin Pinto
Marvin Pinto

Reputation: 31038

I usually use a screen session for when I need to run similar long-running operations on remote machines.

It becomes easy to join or detach the session whenever I log in or out of the server. The added bonus is that it saves all the stdout/stderr output for when you get back.

Upvotes: 4

Max Manders
Max Manders

Reputation: 51

Might need more specifics, but in general I think you'll want to look in to nohup or daemonising the process to detach it from the parent shell process.

Upvotes: 3

Related Questions