Persistent SSH sessions with screen

Do you ever need to kick off a long-running command while SSHed to a server, but be able to disconnect and reconnect at will? You can do this with screen.

Before doing anything, start a screen session:

screen

When you’re ready to put your work on hold, detach the screen:

screen -d

If you have a long-running command running, you can detach that screen from a different shell session by specifying the process id:

# look up the process id
ps aux | grep SCREEN
# detach that screen
screen -d <my_process_id>

You can now disconnect from the server safely.

When you reconnect, you can also reconnect to your screen session:

screen -r

 

Comments

One response to “Persistent SSH sessions with screen”

  1. Marcus Bennett Avatar
    Marcus Bennett

    Of course this works well but relies on screen being installed. For AIX therefore since it is not I would recommend http://www.perzl.org/aix/index.php?n=Main.Screen

Leave a Reply to Marcus Bennett Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.