Logo

HPC @ Uni.lu

High Performance Computing in Luxembourg

This website is deprecated, the old pages are kept online but you should refer in priority to the new web site hpc.uni.lu and the new technical documentation site hpc-docs.uni.lu

Introduction

The GNU Screen utility allows the user to create several virtual consoles inside a single terminal, enabling:

  • the user to connect to a remote system (e.g. Gaia’s frontend) by ssh then start screen and create multiple terminal windows and run applications in each, without the need for additional ssh connections;

  • the decoupling of the terminal from the running applications, thus even if the network connection is broken, or the user needs to disconnect from the remote system, the applications started in screen windows, will keep running and the user can later reconnect to the screen session and continue work.

Basic screen operations

Creating and accessing screen sessions

You start a screen session with:

$ screen -

which will get you back to the shell prompt and you can run your applications, however you are now within screen. To close screen, you can type exit in this shell, and you will be returned to the original shell you started screen in, with the message:

[screen is terminating]

To detach from a screen session, while keeping open the applications started inside you use the key combination CTRL-a d (‘CTRL’ and ‘a’ pressed simultaneously then released and ‘d’ pressed) and you will be returned to the shell you started screen in, however now you will see the message:

[detached from PID.pts-NUM.HOSTNAME]
# e.g on Gaia's frontend:
[detached from 7518.pts-9.access]

and you can now close the connection to that system, and reconnect to this detached screen later.

To find out if you have left one (or more) screen sessions open on a system:

$ screen -ls
There are screens on:
    	7518.pts-9.access       (03/07/2014 06:36:16 PM)        (Detached)

this shows that a session exists and has been disconnected from. Running screen -ls while inside screen will show the session as being “(Attached)”.

To reattach to a detached screen session use:

$ screen -x

or if multiple screen sessions exist, you can reattach to a specific one with:

$ screen -x SESSION_ID
# e.g.
$ screen -x 7518.pts-9.access

Screen window operations

After starting a screen session, several operations are available through key combinations:

  • CTRL-a c : create a new window inside screen, starting your shell

  • CTRL-a # : switch to a specific window number (where # is 0-9)

  • CTRL-a “ : show a list of open windows, you can switch to one of them with the arrow keys and ENTER

  • CTRL-a-a : quickly switch to the previously opened window

  • CTRL-a d : detach from the screen session

  • CTRL-a S : horizontally split the current screen window in two views; one will be empty and you must move to it (see below) and either create a new window there or open an existing one

  • CTRL-a TAB : move between split windows

  • CTRL-a X : remove the current split view (does not close the window)

  • CTRL-a | : perform a vertical split (not available in all distributions of screen)

  • CTRL-a [ : enter copy mode, which allows:
    • to scroll back in screen history with the arrow keys
    • to set start and end copy markers with ENTER or SPACE
    • exit copy mode with ESC
  • CTRL-a ] : paste the copied content (see above) into the current window

  • CTRL-a k : kill the current window and the application running inside (useful if the application is blocked)

  • CTRL-a ? : show the help menu

Example usage on UL HPC

(laptop)$ ssh access-iris.uni.lu
(access-iris)$ screen -
(access-iris)$ oarsub -I
(gaia-node)$ ./your_application > application.log
CTRL-a c
(access-iris)$ tail -f application.log
# assuming here the network connection has failed, but the interactive OAR job, your_application
# and tail are still running;  we need now to reconnect to gaia and the screen session
(laptop)$ ssh access-iris.uni.lu
(access-iris)$ screen -x
# back in screen, we are in the last opened window where tail is still running
(access-iris)$ tail -f application.log
CTRL-a d
(access-iris)$ [detached from 18183.pts-3.access]
(access-iris)$ exit
(laptop)$

Troubleshoot