Reputation: 41
I'm using screen to run a lot of different instances of an application and I name the the sessions "app1", "app2" etc.
The problem is that if I have a screen named "app10" started after the one named "app1", when I type
screen -r app1
I get attached to the app10 screen because it's the last screen created "matching" the name app1.
Is it possible to get rid of name matching and use exact names ?
For technical reasons I don't want to change app1 to app01. It's used in directory name, automation etc.
Upvotes: 3
Views: 1006
Reputation: 18807
As you rightly pointed out, screen uses the parameter value as a prefix.
A long alternative would be to type:
screen -r $(basename /var/run/screen/S-$USER/*.app1}
(presuming that your sockets are in the /var/run/screen directory which is the default on Debian systems)
You can create an equivalent bash function in your .bashrc
file
function mscreen() {
screen -r $(basename /var/run/screen/S-$USER/*$1)
}
which let you type
mscreen app1
to recover your session app1
and not app10
Upvotes: 3
Reputation: 3801
You can use pid
prefix for that purpose:
man screen
-r [pid.tty.host] -r sessionowner/[pid.tty.host] resumes a detached screen session. No other options (except combinations with -d/-D) may be specified, though an optional prefix of [pid.]tty.host may be needed to distinguish between multiple detached screen sessions. The second form is used to connect to another user's screen session which runs in multiuser mode. This indicates that screen should look for sessions in another user's directory. This requires setuid-root.
Upvotes: 0