This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this questionI'm using the Screen multiple开发者_StackOverflow社区xer tool on the command shell and open a lot of screens. I then forget which process ID associates with which task.
I would like to set a name for a screen, but I can't find an option in the man page.
Currently, listing the screens looks like this:
There are screens on:
5422.pts-1.aws1 (Detached)
5448.pts-1.aws1 (Detached)
5027.pts-1.aws1 (Detached)
3 Sockets in /var/run/screen/S-sb.
And I would like to see something like this:
There are screens on:
5422.logCleanWorker (Detached)
5448.overNightLongTask(Detached)
5027.databaseOverNightLongTask (Detached)
3 Sockets in /var/run/screen/S-sb.
How can I do this?
To start a new session
screen -S your_session_name
To rename an existing session
Ctrl+a, : sessionname YOUR_SESSION_NAME Enter
You must be inside the session
To create a new screen with the name foo
, use
screen -S foo
Then to reattach it, run
screen -r foo # or use -x, as in
screen -x foo # for "Multi display mode" (see the man page)
As already stated, screen -S SESSIONTITLE
works for starting a session with a title (SESSIONTITLE
), but if you start a session and later decide to change its title. This can be accomplished by using the default key bindings:
Ctrl+a, A
Which prompts:
Set windows title to:SESSIONTITLE
Change SESSIONTITLE
by backspacing and typing in the desired title. To confirm the name change and list all titles.
Ctrl+a, "
The easiest way is to use Screen with a name:
screen -S 'name' 'application'
- Ctrl + a, d = exit and leave the application open
Return to Screen:
screen -r 'name'
For example, using Lynx with Screen.
Create a screen:
screen -S lynx lynx
Ctrl+a, d = exit
Later, you can return with:
screen -r lynx
I am a beginner to Screen, but I find it immensely useful while restoring lost connections.
Your question has already been answered, but this information might serve as an add on - I use PuTTY with PuTTY connection manager and name my screens - "tab1", "tab2", etc. - as for me the overall picture of the 8-10 tabs is more important than each individual tab name. I use the 8th tab for connecting to db, the 7th for viewing logs, etc. So when I want to reattach my screens I have written a simple wrapper which says:
#!/bin/bash
screen -d -r tab$1
where first argument is the tab number.
精彩评论