[vox-tech] possible to exit ssh with a program running?

vox-tech@lists.lugod.org vox-tech@lists.lugod.org
Thu, 23 Oct 2003 09:03:51 -0700


On Thu 23 Oct 03,  8:17 AM, Jonathan Stickel <jjstickel@myrealbox.com> said:
> I know that if I start a terminal window in X, run a program, and then 
> manually close the window, the program dies.  I also know that if I 
> secure-shell into another machine and run a program, I cannot exit 
> without first ending that program.
> 
> Is there any way to start a program for a shell window and leave it 
> running when I close the window?  Also, is there anyway to leave a 
> program running remotely, started through an ssh session, and exit ssh?
> 
> The later would be very helpful, although I suspect these two issues are 
> related.  My research involves running computer simulations on several 
> computers on campus.  I would really like to ssh into the machines from 
> home, start the simulations (which generate output to text files), and 
> then exit the ssh sessions with the simulations in progress.  This way I 
> could close my internet connection (dial-up :( ) and turn my home 
> computer off while the multi-day simulations run.
> 
> Is this possible?
> 
> Jonathan

very possible, as nicole and tim pointed out with nohup and background
operator.

however, if your simulations are like mine, they spit out useful
information every once in a while like whether the simulation has lost
too much precision or how near it is to completion.

screen might be a better choice if this is the case.  simply
instructions:

1. log into the machine that will run the simulation.
2. run screen.
3. start your simulation.
4. type ^d to detach your screen session.
5. log out.

whenever you want to check up on your simulation, you can:

1. ssh back into the machine
2. run screen
3. your session will be restored
4. type ^d to detach it again if your simulation isn't done.


for completeness, i used to use cron and atd for this same purpose.  atd
worked well.  but screen is a much better solution.  i was a newbie back
then.  :)

also, i've found this helpful:

./mysimulation ; mail -s "i'm done" jon@myemailaddress.edu

so you know when the thing is done and don't have to keep checking back
every few hours.

hth,
pete

-- 
GPG Instructions: http://www.dirac.org/linux/gpg
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D