Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-19-2009, 03:20 AM   #1
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Rep: Reputation: 45
screen command leaves pid open on ssh server

I reverse tunnel from a notebook to a ssh server.

A script runs at startup and opens tunnel no problem. Except when the notebook is shutdown, the tunnels ssh pid stays open on the server. It results in a port forwarding error whenever the notebook restarts, because the port is still open and is reserved on the ssh server.

Example on the ssh server:

tcp        0      0  *               LISTEN     9021/1
So this pid stays open even when the notebook shuts down or restarts. This is all invoked by the notebook script.

Notebook command:

screen -d -m ssh -l username -R <port>:
This means I have to kill the pid manually on the ssh server before the notebook can ssh again after any restart.

Is my screen commands wrong..?
Old 08-19-2009, 04:10 AM   #2
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (
Posts: 1,900

Rep: Reputation: 69
I think you want to put 'autodetach off' into .screenrc on server.
Old 08-19-2009, 05:07 AM   #3
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Original Poster
Rep: Reputation: 45
The screen is used on the notebook not the server ( I guess I don't understand screen well enough)

What I did is added "autodetach off" to ~/.screenrc of the notebook. And then restarted the notebook.

netstat -anp | grep :<port>
on the server to see if it had killed the pid that the notebook opened, and it was still listening on the port with the same pid.

So again I had to kill the pid on the server quickly. Before the notebook script executed on startup.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
(bind) named: couldn't open pid file '/var/run/named/' - any help? samengr Linux - Server 6 04-01-2009 06:22 AM
xscreensaver leaves bad screen settings vit0cf Linux - Desktop 1 03-29-2009 07:13 AM
Exiting from X windows leaves screen to dark after upgrade to 12.1 hsrthe4th Slackware 9 05-08-2008 10:58 PM
Passwordless SSH with SSH commercial server and open ssh cereal83 Linux - General 7 04-18-2006 12:34 PM
Mouse leaves trails on the screen. Jaster150 Linux - Software 2 09-22-2004 01:20 AM > Forums > Linux Forums > Linux - Software

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

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