Screen is a handy tool that can help you run scripts on servers remotely without having to worry about the session getting terminated. It seems to operate kinda like a virtual console.
Create Screen Session
Create a new session with a specified name
screen -S SessionName
Example output below. Create session named testsession and print screen sessions.
[bob@localhost imapsync]$ screen -S testsession
[bob@localhost imapsync]$ screen -ls
There are screens on:
3313.testsession (Attached)
1 Sockets in /var/run/screen/S-bob.
[bob@localhost imapsync]$
Disconnect from Screen Session
You can disconnect from a screen session by hitting ctrl + a and then ctrl +d
“ctrl + a” then “ctrl + d”
List Screen Sessions
You can list the screen sessions with
screen -ls
Example
[bob@localhost imapsync]$ screen -ls
There are screens on:
3212.testsession (Detached)
2556.xap (Detached)
2 Sockets in /var/run/screen/S-bob.
[bob@localhost imapsync]$
Connect to screen Session
You can reconnect to a screen session with
screen -r testsession
Terminate Screen Session
To terminate a screen session, connect to that session and then on a clear line hit ctrl + d
Same way as if you were closing a remote ssh connection.