General *nix question

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

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 :slight_smile: 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?

You had other type of problem

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.


use VICM3 for a full 97USD discount on your first year!

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 :stuck_out_tongue:

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.

use VICM3 for a full 97USD discount on your first year!

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

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.

Read my blog. You know you want to…

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 :stuck_out_tongue: