AI Crawler · Collection Records

Bot summary · Last 24 hours

screen — session persistence (traditional tool)

A session persistence tool used before tmux. Still used because many environments have it installed by default.
Markdown source·Anything to add or correct?

💬 "screen command"

screen is a session persistence tool with the same purpose as tmux. It is often installed by default on older servers.

The prefix key is Ctrl+a, followed by a key combination.

  • Concept: You can create terminal sessions and detach or reconnect to them.
  • Prefix key: Press Ctrl+a followed by a command key.
  • Detach/reattach: Detach with Ctrl+a d and reattach with screen -r.
  • List: View the session list with screen -ls.

Common options

OptionDescription
-S <name>Creates a named session
-r <name>Reconnects to a session
-lsDisplays the session list
-dmS <name>Starts a session detached

Three essential command combinations

  • screen -S deploy — Create a deploy session
  • screen -ls — Check the session list
  • screen -dmS batch bash -lc '/opt/app/bin/batch.sh' — Run a batch job in a detached session

💬 "Show me examples of the most commonly used combinations in practice"

The following is a step-by-step summary of situations commonly encountered on production servers.

Step 1 · Create a session

Create a session for your work.


screen -S deploy

Step 2 · Run the task

Run the long-running task inside the session.


./bin/deploy.sh 2>&1 | tee /tmp/deploy.log

Step 3 · Detach/reconnect

Exit with Ctrl+a d and reconnect.


screen -r deploy

How this is used in practice

1. Long-running work in a default installation environment

Situation — A server where tmux is not installed and only screen is available.


screen -dmS deploy bash -lc 'cd /opt/app && ./bin/deploy.sh > /tmp/deploy.log 2>&1'

Result — The session runs the deployment in the background.

Point — Write the output to a file so you can check it without reconnecting.

2. Session cleanup

Situation — Old screen sessions have accumulated.


screen -ls

Result — The list appears with (Detached)/(Attached) statuses.

Point — Sessions left Attached may be in use by someone, so do not kill them without checking.

Important notes

  • The prefix key differs from tmux, so it is easy to confuse them (Ctrl+a).
  • Forcefully detaching an Attached session with -d can affect another user's work.
  • Sessions disappear when the server reboots.

Actual output

This is the result of checking the detached screen session list.

!screen command output: session list

Production server


Source (HTML): https://games.aidebatehub.com/programs/linux/remote/screen.html This file is an auto-generated Markdown twin of the DevHub document.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:30:59+09:00