Sponsored Content
Operating Systems Linux Is it possible to set timeout on Linux screen session Post 303011017 by prvnrk on Thursday 11th of January 2018 08:39:16 PM
Old 01-11-2018
Hi Corona688, it's actually NOT working. Even though we're able to kill the bash (shell) but the screen session socket still exists (that's the whole point of having a session - not to lose session if there's disconnection to the server etc.). Just login into the server and running "screen -r" still restores my session and one can see what is going on the session.

So I changed your script as below and now its working fine ( basically I'm killing the screen session)
Code:
( sleep 120 && screen -S scr1 -X quit ) & # Kill screen session in 2 minutes
exec screen -S scr1 # Establish a screen session

Luckily screen offers us to name every session so you can use that name (instead of PID which is a random number) to kill/attach/detach. Now It's working as expected. Thanks for all the help!

Last edited by prvnrk; 01-11-2018 at 10:13 PM..
This User Gave Thanks to prvnrk For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

telnet session timeout

hi, we can set something such that if the user has been idle for a while, it will auto disconnect. where to do so? thanks (6 Replies)
Discussion started by: yls177
6 Replies

2. Solaris

Setting Screen Lock Timeout

Hello; I have Solaris 2.6 installed on many Sun AXI Ultra Sparc IIi systems. I want to set the Lock Screen global timeout for all users to 15 minutes. I read the Solaris CDE guide which instructed me to create a /etc/dt/config/C/sys.resources file and changed the timout to 15 minutes in... (1 Reply)
Discussion started by: rambo15
1 Replies

3. Solaris

Solaris 8 - Session timeout

Hi, anyone Audit requirement to set the Solaris 8 server session timeout to 180 sec , Please advice how can I do it .... Thanks (3 Replies)
Discussion started by: civic2005
3 Replies

4. Shell Programming and Scripting

session timeout for shell script

I am executing test.sh script. But this script takes lot of time and in the meantime the shell timeouts without completing the script. Is there any command which will continue processing the script. Thanks (3 Replies)
Discussion started by: infyanurag
3 Replies

5. AIX

Unix session timeout?

We recently moved servers to a new data center, and now we're experiencing user sessions timing out after non-activity. We didnt experience this before, or know of any timeout settings that may have been changed. Any things I can check out on the server? (3 Replies)
Discussion started by: NycUnxer
3 Replies

6. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

7. UNIX for Dummies Questions & Answers

Putty Session Timeout

Hi, I had add the following line into .profile and .bash_profile for the timeout session to avoid putty close automatically : timeout=10800 However, i still keep encounter session time out every after 60 seconds. Can anyone please help advice. Many Thanks! (2 Replies)
Discussion started by: wancy
2 Replies

8. Solaris

Session timeout setting in server

Hi All I need to set timeout of login session of a user if a user is idle for some time. I know the TMOUT setting but it work with only BASH & KORN shell only as I need to set for Bourne shell also. I am trying to put "ClientAliveInterval 300" in sshd_config & restart or refreshing the... (1 Reply)
Discussion started by: sb200
1 Replies

9. AIX

Set timeout value for ssh session to HMC?

Friends, Could anyone let me know - how to set the timeout value for ssh session to HMC? My HMC version is -- V7R7.4.0. I'm sure the version doesn't have anything to do with it. Thanks, -- Souvik (2 Replies)
Discussion started by: thisissouvik
2 Replies
dtach(1)						      General Commands Manual							  dtach(1)

NAME
dtach - simple program that emulates the detach feature of screen. SYNOPSIS
dtach -a <socket> <options> dtach -A <socket> <options> <command...> dtach -c <socket> <options> <command...> dtach -n <socket> <options> <command...> DESCRIPTION
dtach is a program that emulates the detach feature of screen. It is designed to be transparent and un-intrusive; it avoids interpreting the input and output between attached terminals and the program under its control. Consequently, it works best with full-screen applica- tions such as emacs. dtach is intended for users who want the detach feature of screen without the other overhead of screen. It is tiny, does not use many libraries, and stays out of the way as much as possible. SESSIONS A session in dtach is a single instance in which a program is running under the control of dtach. The program is disassociated from the original terminal, and is thus protected from your original terminal being disconnected for some reason. Other instances of dtach can attach themselves to a particular session. Input and output is copied between the program running in the dtach session, and the attached terminals. dtach avoids interpreting the communication stream between the program and the attached terminals; it instead relies on the ability of the attached terminals to manage the screen. Sessions are represented by Unix-domain sockets in the filesystem. No other permission checking other than the filesystem access checks is performed. dtach creates a master process that monitors the session socket, the program, and any attached terminals. MODES dtach has several modes of operation. It can create a new session in which a program is executed, or it can attach to an existing session. The first argument specifies which mode dtach should operate in. -a Attach to an existing session. dtach attaches itself to the session specified by <socket>. After the attach is completed, the win- dow size of the current terminal is sent to the master process, and a redraw is also requested. -A Attach to an existing session, or create a new one. dtach first tries to attach to the session specified by <socket> if possible. If the attempt to open the socket fails, dtach tries to create a new session before attaching to it. -c Creates a new session. A new session is created in which the specified program is executed. dtach then tries to attach itself to the newly created session. -n Creates a new session, without attaching to it. A new session is created in which the specified program is executed. dtach does not try to attach to the newly created session, however, and exits instead. OPTIONS dtach has a few options that allow you to modify its behavior. Each attaching process can have separate settings for these options, which allows for some flexibility. -e <char> Sets the detach character to <char>. When the detach character is pressed, dtach detaches itself from the current session and exits. The process running in the session is unaffected by the detach. By default, the detach character is set to ^ (Ctrl-). -E Disables the detach character. dtach does not try to scan input from the terminal for a detach character. The only way to detach from the session is then by sending the attaching process an appropriate signal. -z Inhibits processing of the suspend key. Normally, dtach will suspend itself when the suspend key is pressed. With this option, the suspend character is sent to the session instead of being handled by dtach. EXAMPLES
The following example creates a new session that has the detach character and suspend processing disabled. A socket is created in the /tmp directory for the session. $ dtach -c /tmp/foozle -Ez bash The following example attaches to the /tmp/foozle session if it exists, and if not, creates a new session using /tmp/foozle as the socket for the session. Processing of the suspend character is also disabled for the attach instance. $ dtach -A /tmp/foozle -z bash AUTHORS
Ned T. Crigler <crigler@hell-city.org>. SEE ALSO
screen(1) dtach 0.5 November 2001 dtach(1)
All times are GMT -4. The time now is 11:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy