LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-29-2015, 03:04 PM   #1
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Rep: Reputation: Disabled
How long can a Screen session I start on a server run for, if I detach and disconnect


Hello,

So I'm doing some work on a remote PC via SSH (inside a Screen session), and I'm noticing that I'm getting errors if I'm not connected for some amount of time. There's usually no problem if i reconnect and reattach the screen after an hour or two, but if I'm disconnected overnight, I log back and find that whatever I was doing threw an error. The screen session still exists, but the work has stopped.

Is this expected behavior?
 
Old 04-30-2015, 02:45 AM   #2
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
I have different experiences with screen.
Session just run overnight on most servers I used.
Maybe it is somewhere in the settings of that server?
 
Old 04-30-2015, 03:07 AM   #3
Patric.F
Member
 
Registered: Feb 2010
Posts: 47

Rep: Reputation: 0
I've never had that issue with screen at all. I have a screen session without being attached to it for days and it runs just fine 24/7.
Maybe it's the program that you are running inside the screen that is the problem? Or do you get the same behavior if you run different programs?
I have stuff like rTorrent and Irssi in a screen session without attaching to it for a very long time and I can't say that I've experienced the symptoms you are saying.
So I would say no, it's not an expected behavior.

What distro and version of screen are you using?

/Patric
 
Old 04-30-2015, 06:05 AM   #4
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
its screen 4.0.3-14ubuntu.

What happens is that I have a script running on the server that constantly executes matlab, runs a single command, takes the output from console and repeats (dont ask. ugh. )

I just left my client PC open overnight, the putty session had keepalive 1800 configured, and the ssh gateway from which i connect to the server also had keepalive on the ~/.ssh/config file, and I had left one of the screens displaying 'top'

When i came back, the putty ssh session was timed out, and when I logged back in and reattached the screen, the script was crashed.

The error message was "permission denied" on the command that runs matlab.

Last edited by ahegao; 04-30-2015 at 06:17 AM.
 
Old 04-30-2015, 07:01 AM   #5
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
I usually run screen and detach all screens before logging out of putty.
That way the commands just run without any information moving over ssh.
Did you try this as well?
 
Old 04-30-2015, 07:05 AM   #6
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hoes View Post
I usually run screen and detach all screens before logging out of putty.
That way the commands just run without any information moving over ssh.
Did you try this as well?
no i didn't. I was attached to the screen when putty timed out. Does detaching really make things work differently?
 
Old 04-30-2015, 07:19 AM   #7
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
Yes, that is the whole point of screen.
With detaching the screen you decouple it from your putty session.
That way the command in your screen is alive even when you close your putty session.
And you can open the screen in a different login session.
I usually use a detached screen as an insurance for command that run a long time.
That way i can be sure the command continues regardless of a connection timeout.
 
Old 04-30-2015, 07:21 AM   #8
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
AUGH i thought that screen was independent regardless of if I was attached to it or not...

So just to understand this correctly, if I'm sshed into an attached screen and the ssh times out, this does not 'count' as detaching the screen and the screen is not independent when the putty times out and it breaks. But if i detach, it is then independent.
 
Old 04-30-2015, 07:44 AM   #9
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
You got it.
Also look at http://www.workhabit.com/blog/best-p...h-alive-screen
 
Old 04-30-2015, 04:40 PM   #10
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Ok unfortunately this didn't work.

I detached the screen this time (but had left putty open, sitting OUTSIDE of the screen tho.) After like 8 hours, the job inside the screen crashed with error "key has expired" . My SSH session didn't actually time out, but I could execute no commands inside or outside of screen. even "ls" gave error "cannot execute, key has expired"
 
Old 05-01-2015, 12:59 AM   #11
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
But then the question is whether you can set up a new SSH connection that could attach the screen.
 
Old 05-01-2015, 01:25 AM   #12
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
no not really. The SSH connection had nothing to do with the timeout. The screen lost I/O permissions regardless of the SSH session. I was detached this time. And also tonight it happened again with a completely closed ssh session and a detached screen doing work.
 
Old 05-01-2015, 01:30 AM   #13
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ahegao View Post
I detached the screen this time (but had left putty open, sitting OUTSIDE of the screen tho.) After like 8 hours, the job inside the screen crashed with error "key has expired" . My SSH session didn't actually time out, but I could execute no commands inside or outside of screen. even "ls" gave error "cannot execute, key has expired"
The "key has expired" message does not sound like something a problem with SSH or screen. What you could do to diagnose this is to start a new screen session, then key combo CTRL-A, SHIFT-H to start a screen log and then start your application and then detach. When you re-attach check stdout / stderr / screen log for the message and whatever surrounding lines and post those here if you can't fix it yourself. *Note that for running attached screen sessions for hours on end Linux has 'autossh', which re-establishes connections when they get interrupted, but obviously the Other OS doesn't offer an equivalent.
 
Old 05-01-2015, 01:45 AM   #14
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 190

Rep: Reputation: 51
Also, if I google "key has expired". One of the first things that pops up is problems with samba or cifs mounts.
If you say that you cannot even do ls outside the screen the problem might not be with screen after all.
 
Old 05-01-2015, 04:42 AM   #15
ahegao
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Ok some clarification:

This error has happened to me over 5-6 times now AFTER I mentioned the "Key has expired" error messages. In all of those subsequent errors, the error was "Permission denied" instead, and not key has expired. So, sorry for that confusing part. I'm not sure why the 1st case had a different error message either. Maybe because i was idling in the SSH session (detached screen) instead of just logging out.

Here's the actual stderr file from my script trying to execute matlab:

Code:
sh: 1: /vol/share/software/matlab/******/r2012b/bin/matlab: Permission denied
This happens after:

1. I ssh to the target host.
2. start a screen.
3. run my job.
4. detach screen
5. log out
6. log back in a while after. Reattach screen. Everything is working normally, but process has terminated with the above error. Commands now work normally.



Quote:
The "key has expired" message does not sound like something a problem with SSH or screen. What you could do to diagnose this is to start a new screen session, then key combo CTRL-A, SHIFT-H to start a screen log and then start your application and then detach. When you re-attach check stdout / stderr / screen log for the message and whatever surrounding lines and post those here if you can't fix it yourself. *Note that for running attached screen sessions for hours on end Linux has 'autossh', which re-establishes connections when they get interrupted, but obviously the Other OS doesn't offer an equivalent.
I'm not sure if the stderr that my work already logs will produce the same output, so I'll try doing this


Quote:
Also, if I google "key has expired". One of the first things that pops up is problems with samba or cifs mounts.
If you say that you cannot even do ls outside the screen the problem might not be with screen after all.
Again, this was a special case that only happened the first time. I think it happened because i was idling in the SSH session but your guess is as good as mine honestly :/ This is very confusing. The typical behavior is as I described above.

Last edited by ahegao; 05-01-2015 at 04:51 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can't detach from screen session which runs java application joe_2000 Programming 12 03-16-2013 06:46 PM
[SOLVED] Run screen session in a screen session. eyanu Linux - Newbie 4 10-01-2012 01:50 AM
Trying to start a GNU screen session at startup th_alton Linux - Newbie 2 09-10-2009 03:31 PM
How to run xmodmap at the start of an X session? johnsfine MEPIS 4 06-02-2009 09:00 AM
screen command doesn't start new session darklor Linux - General 1 12-22-2008 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration