Results 1 to 5 of 5
I am using ssh -X to access directories and folders remotely. I am running a code that takes about 55 minutes to run per file on a list of files ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-21-2013 #1
- Join Date
- Nov 2012
Remote Log in Time-out?
I am running a code that takes about 55 minutes to run per file on a list of files (over and over again).
I notice that if I am physically working at the computer (from which I am remotely logging into the other computer in one terminal), that the script can continue to run through the list of files.
However, when I leave to go home, I come back the next day, and see that the script just stops midway through running the code on a file (usually the same file it had been on, or only the very next file).
What can I do to ensure that the script being run remotely can continue until it reaches the end? What is causing this exactly?
And yes, I am quite new at this stuff :o)
Thanks in advance....
- 01-21-2013 #2
Have a look at screen or tmux.
You would log in via ssh as usual, then start a screen or tmux session.
These can be safely detached. So you do not need a constant ssh connection.
man screen man tmux
As for the disconnect: Yes, there is a ssh timeout and also a tcp timeout.
Once there is is no action for X amount of time, they will close for cleanup and resource reasons.
There are the ServerAliveInterval and TCPKeepAlive directives to be used in the ssh config.
This is a snippet of my ~/.ssh/config
ForwardAgent yes ForwardX11 no ServerAliveInterval 15 TCPKeepAlive no
In your usecase, I would use screen or tmux.You must always face the curtain with a bow.
- 01-21-2013 #3
- Join Date
- Nov 2012
Thank you for your reply, Irithori.
I have nothing under 'man tmux'. I do have information listed under 'man screen'. So I will use that command.
You are saying I need to remote log in (via ssh), then "start a screen".
My program freezes halfway through a code after I physically leave the computer. When I come back the next day and see the program frozen, I use Ctrl+C, and get the following message in the terminal "Write failed: Broken pipe". Are you saying that by "starting a screen" (on the remote terminal, I am assuming?) right after remote accessing (and no additional commands), that this problem could be prevented, and the computer would continue to run the remote code, even if I physically leave the computer?
I am trying to put this together, and if possible, could someone help with the following two questions? :
1) I am not sure how to "start the screen". Is it simply a one-line command, or multiple lines and processes? What options should I look at in 'man screen'. Is the -r option sufficient?
2) What is causing the remote terminal to stop the code? It seems that if I am working on the computer I am at physically, even if I do nothing additional in the remote computer after starting the script, that the remote script will continue. So it seems to be a problem on the current computer, because whether or not I am physically present here, has the ability to terminate the remote code. But the solution is still to "start a screen" on the remote computer?
Yes, yes, I really meant it when I said I was a newbie, and sorry if the elementary and incorrect terminologies are horrific to witness :o)
- 01-22-2013 #4
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
As Irithori indicated, either your ssh session is timing out (need the ServerAliveInterval set appropriately) or the TCP connection is (set TCPKeepAlive to 'yes'). However, sometimes this still won't work, depending upon the settings for the server (remote) system sshd. What most people do to keep scripts/processes running if the terminal shuts down is to run them with the "nohup" command. See the nohup man page for more information.
Just remember, Semper Gumbi - always be flexible!
- 01-22-2013 #5
As for 2) As said before: ssh/tcp timeouts due to non-actions
As for 1) See here for a very brief introduction to screen
ssh <YOUR_REMOTE_MACHINE> screen
Now run any command you like, maybe a long running like top.
(Simultaneously press the "ctrl" key and the "a" key, then press the "d" key)
You are back to your ssh login shell.
It can be safely closed now, ie you can disconnect ssh if you wish. top will continue running.
The next time you login, you can reattach the screen session:
ssh <YOUR_REMOTE_MACHINE> screen -list screen -r <SESSION_NUMBER>
If you wish to close the screen session, just call exit.You must always face the curtain with a bow.