Using Terminal Screen Command

This is a simple one. For some reason, every time I use the screen command in terminal, I forget the commands.

There are probably lots of cool reasons to use screen but I use it to run a script over a longish period. The advantage of screen is I can start the script in the screen instance and detach from it. I can close my laptop and return later to my terminal, open my screen and check the progress of the script. Also, you can run multiple instances of a script as each screen has its own process.

So the basic commands I use and tend to forget are…

Create a screen with a label so you know what it’s for: screen -S 'run-long-script1'

Detach from the screen: Ctrl + a + d

Kill the screen: exit

Check what screens you have created: screen -ls

Open a screen that you have already created: screen -r 'run-long-script1'

Access the extensive screen manual: man screen

Found this guide helpful from thegeekstuff.

3 thoughts on “Using Terminal Screen Command

  1. here’s another hint for running in Terminal on Mac OS X. I have this in my .bashrc:

    alias screen1=’screen -t kevin1 -d -R kevinone -e^Gg’
    alias screen2=’screen -t kevin2 -d -R kevintwo -e^Gg’
    alias screen3=’screen -t kevin3 -d -R kevinthree -e^Gg’

    Thus, I can type screen1, screen2, or screen3 to either start or resume a previous session. Also, using these aliases allows you to use Ctrl-A (emacs keybindings) to go to the beginning of the line. Otherwise, Ctrl-A will kill your session. (not fun)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s