Reputation: 349
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
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
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
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