Reputation: 534
To create a screen, I am currently doing:
screen -dmS screenname ./file
That works perfectly, however killing it remotely with:
screen -X -S screenname exit
Will reply with:
No screen session found
This is due to the screen having {session#}.{screenname}
It will work if done as:
screen -X -S session#.screenname exit
What solutions are possible? I'm not entirely sure that you can get the session# when you start the screen. This is all done remotely too.
Upvotes: 1
Views: 232
Reputation: 1280
screen -ls | grep detached | cut -d. -f1 | awk '{print $1}' | xargs kill
This will kill all the detached screens
screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
this will kill all the screen whether attached or detached doesn't bother
Upvotes: 0
Reputation: 150
I also start screens with the -dmS option, and I send commands to the screen using the stuff command:
$ screen -dmS screenname
$ screen -ls
There is a screen on:
22941.screenname (Detached)
1 Socket in /var/run/screen/S-user.
$ screen -S screenname -p 0 -X stuff "exit$(printf \\r)"
$ screen -ls
No Sockets found in /var/run/screen/S-user.
$
more details on "stuff" are in the screen man page, search for 'stuff string'
Upvotes: 1