Wednesday, May 1, 2024
129
rated 0 times [  129] [ 0]  / answers: 1 / hits: 408986  / 2 Years ago, sat, november 12, 2022, 1:40:55

I have a program running under screen. In fact, when I detach from the session and check netstat, I can see the program is still running (which is what I want):



udp        0      0 127.0.0.1:1720          0.0.0.0:*                           3759/ruby       


Now I want to reattach to the session running that process. So I start up a new terminal, and type screen -r



$ screen -r
There are several suitable screens on:
5169.pts-2.teamviggy (05/31/2013 09:30:28 PM) (Detached)
4872.pts-2.teamviggy (05/31/2013 09:25:30 PM) (Detached)
4572.pts-2.teamviggy (05/31/2013 09:07:17 PM) (Detached)
4073.pts-2.teamviggy (05/31/2013 08:50:54 PM) (Detached)
3600.pts-2.teamviggy (05/31/2013 08:40:14 PM) (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.


But how do I know which one is the session running that process I created?



Now one of the documents I came across said:



"When you're using a window, type C-a A to give it a name. This name will be used in the window listing, and will help you remember what you're doing in each window when you start using a lot of windows."



The thing is when I am in a new screen session, I try to press control+a A and nothing happens.


More From » command-line

 Answers
7

There are two levels of "listings" involved here. First, you have the "window listing" within an individual session, which is what ctrl-A A is for, and second there is a "session listing" which is what you have pasted in your question and what can also be viewed with screen -ls.



You can customize the session names with the -S parameter, otherwise it uses your hostname (teamviggy), for example:



$ screen


(ctrl-A d to detach)



$ screen -S myprogramrunningunderscreen


(ctrl-A d to detach)



$ screen -ls

There are screens on:
4964.myprogramrunningunderscreen (05/31/2013 09:42:29 PM) (Detached)
4874.pts-1.creeper (05/31/2013 09:39:12 PM) (Detached)
2 Sockets in /var/run/screen/S-paul.


As a bonus, you can use an unambiguous abbreviation of the name you pass to -S later to reconnect:



screen -r myprog


(I am reconnected to the myprogramrunningunderscreen session)


[#30935] Sunday, November 13, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tionavocad

Total Points: 189
Total Questions: 101
Total Answers: 118

Location: Liechtenstein
Member since Wed, Dec 8, 2021
2 Years ago
tionavocad questions
Tue, May 23, 23, 00:07, 1 Year ago
Tue, Jan 17, 23, 20:38, 1 Year ago
Sun, Oct 10, 21, 04:50, 3 Years ago
Tue, Jun 7, 22, 08:50, 2 Years ago
;