Use reasons

Usually, the command is executed on the terminal, and the terminal breaks down for a long time. At this point, you can use Screen to maintain the session.

Screen effect

Unified interface for managing multiple sessions and corresponding functions. Can maintain the session.

Common commands

  1. Lists all sessions: screen-ls
  2. Create and name a session: screen-s [your session name]
  3. Delete session: screen -s [your session name] -x quit
  4. Enter session: screen-r [name of your session]
  5. Exit the current session: Ctrl+ A D (hold down Ctrl, A, and D keys simultaneously)

example

Screen-ls lists all sessions. Currently there are two sessions, test1 and test2. The session ID is 26280 and 26287 characters.

There are screens on:
	26280.test1	(Detached)
	26287.test2	(Detached)
2 Sockets in /var/folders/hl/zk07rrxs0kd7vb70w08q6zkr0000gn/T/.screen.
Copy the code

2. Create a session screen -s test3 and name it. After the session is created, the system directly jumps to the terminal on test3. At this point, type the command you want to execute, such as:

Bash - 3.2 $nodetest3.js
Copy the code

3. Exit the current session: Ctrl+a d 4. Screen-ls list all sessions.

There are screens on:
	26280.test1	(Detached)
	26287.test2	(Detached)
	26387.test3	(Detached)
3 Sockets in /var/folders/hl/zk07rrxs0kd7vb70w08q6zkr0000gn/T/.screen.
Copy the code

5. To access test3 again, run screen -r test3 (or screen -r 26387) 6. To delete the session, run screen -s test3 -x quit (or screen -s 26387 -x quit) 7. Finally, screen-ls is executed. Now there are two sessions left

There are screens on:
	26280.test1	(Detached)
	26287.test2	(Detached)
2 Sockets in /var/folders/hl/zk07rrxs0kd7vb70w08q6zkr0000gn/T/.screen.
Copy the code