-
Create a new screen with
screen -S name_screen
orscreen
(this will generate an ID of screen) -
OR launch your_command directly with
screen -S name_of_screen your_command
-
then detach it by pressing
Ctrl+A
thend
-
OR launch and detach immediatly with
screen -S name_of_screen -dm your_command
-
you're now back at your main terminal
-
you can list your screens by typing
screen -ls
-
and re-attach your screen by its name with
screen -r name_of_screen
-
to scroll a re-attached screen press
Ctrl+a
then keyEscape
-> you can now move with the arrow keys and pressReturn
twice to go back to the end -
delete a detached screen with
screen -X -S name_of_screen quit
Example :
$ screen -S ping
$ ping 1.1.1.1
# Ctrl + A then press D
# [detached]
$ screen -ls
# There is a screen on:
# 27086.ping (Detached)
# 1 Socket in /var/folders/5l/_m6dn0vj3n556cw2fjd923200000gn/T/.screen.
$ screen -r ping
# PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
# [...]
# 64 bytes from 1.1.1.1: icmp_seq=11 ttl=59 time=2.63 ms
# 64 bytes from 1.1.1.1: icmp_seq=12 ttl=59 time=2.53 ms
# 64 bytes from 1.1.1.1: icmp_seq=13 ttl=59 time=2.48 ms
# Ctrl + A then press D
# [detached]
$ screen -X -S ping quit
$ screen -ls
# No Sockets found in /var/folders/5l/_m6dn0vj3n556cw2fjd923200000gn/T/.screen.