general *nix question

general *nix question

Posted by: telkoth
Posted on: 2007-07-22 13:49:00

I'm not so hot with linux, so I've got a question about something that's driving me nuts :P

I've written my own java app that I'd like to be running all the time. I figured out how to run programs in the background (add the ampersand at the end), however it's never long after I log out that my program ends. At first I thought that my program must be crashing, so I logged its err and out outputs. Finding nothing there, I stayed logged in a while to watch it directly, only to have it never quit :) So as far as I can guess, *nix doesn't like to leave programs hanging around after the person who ran them logs out.

Mmm... what do I do about this? Is there a special way to run programs (add some other non-sense character to the end of the command line? :P) which says "hey! don't close this program!" (in this case, java)?

[edit] or maybe there's a sneaky way to close my SSH connection without logging out the user?Edited by telkoth on 07/22/07 01:51 PM (server time).

Re: general *nix question

Posted by: vicm3
Posted on: 2007-07-22 15:00:00

You had other type of problem
http://wiki.dreamhost.com/Persistent_Processes

you can't run persistent processess... well not allowed and exists a process killer. That searchs and stops processess that consume cpu (or memory) and are persistent.

Regards

Re: general *nix question

Posted by: telkoth
Posted on: 2007-07-22 15:26:00

Only shared servers have that restriction. I am not on a shared server, and the program is quite legal.

[edit] Also, what happens to my account as a result isn't the question here :PEdited by telkoth on 07/22/07 03:35 PM (server time).

Re: general *nix question

Posted by: vicm3
Posted on: 2007-07-22 15:35:00

Well if you need your program to keep on running even if you loggedout you can try
nohup java yourprogram.jar > nohup.log &

or also with screen...

you can launch your program in one "screen" an then detach of screen... an keep it running.

Re: general *nix question

Posted by: telkoth
Posted on: 2007-07-22 15:41:00

nohup - yet another linux feature I was not aware of :P I will try that out - thanks.

Re: general *nix question

Posted by: gordaen
Posted on: 2007-07-23 14:14:00

nohup is what you are looking for (or should be anyway). Adding an ampersand to the end of a command runs it in the background (similar to starting an app and hitting CTRL+Z), so it will still end when the user logs out.

Re: general *nix question

Posted by: telkoth
Posted on: 2007-07-23 14:25:00

oh... well nohup seems to have done just fine. Java's been running for a full day now, whereas previously it would shut down after an hour or so. I did notice that when I run programs in the background and logout (exit), it takes long enough trying to log out to make me just close PuTTy than wait for it >_> Whether or not I'm still logged in as a result or not, I'm not sure. I do, however, know that nohup has solved my problem, and for the time being that's enough :P

Tags: ssh connectionnixssh connectionnixserver timeserver timeampersandampersandmmmmmmnutsnutslinuxlinuxguessguess