User Tools

Site Tools


guides

**This is an old revision of the document!**

Table of Contents

Screen

Introduction

Screen let us, among others things, enter in a linux/unix/mac terminal, start a program or process in it and close it while is running. Later we can retake the job we were running in a new terminal. Sometimes if network is unstable the cluster can reject our connection and lost all the work we were doing, so Screen is useful in this cases (this does not happen if we have sent a job by qsub).

Short tutorial

We learn to use Screen with the program Mr Bayes in a node of the cluster. Without screen we had to keep the terminal open all the time (and if it is closed accidentally MrBayes will be interrupted). So:

  1. Connection with te cluster as usual: ssh <user>@cluster-ceab.ceab.csic.es
  2. Start a screen session with an id label ~$ screen -S pruebaScreen Here we don't notice any change, it's like use the command 'clear'. The prompt ($) will be the same, but now we are inside a 'screen terminal'
  3. Now let's do a qlogin with the resources that we'll need: @cluster-ceab:~$ qlogin -l h_vmem=10G -pe make 4 local configuration cluster-ceab not defined - using global configuration Your job 45946 ("QLOGIN") has been submitted waiting for interactive job to be scheduled ... Your interactive job 45946 has been successfully scheduled. Establishing builtin session to host node108 ... groups: cannot find name for group ID 20500 @node108:~$
  4. Execute the program, in this example, Mr Bayes @node108:~$ mpirun -np 4 /home/soft/mrbayes/src/./mb MrBayes v3.2.4 x64 (Bayesian Analysis of Phylogeny) (Parallel version) (4 processors available) Distributed under the GNU General Public License Type "help" or "help <command>" for information on the commands that are available. Type "about" for authorship and general information about the program. MrBayes > This step is important. Now we will exit from our 'screen terminal' (that's mean go back to a 'normal terminal'). Use 'Ctrl+A' and then push 'D' (detach) or simpler 'screen -d'
[detached from 14868.pruebaScreen]
miguel.omullony@cluster-ceab:~$ 

Now we can exit even from the cluster, our program will keep running

  1. After log in again to cluster-ceab, if we want to reattach to our screen session first we check how many sessions are. miguel.omullony@cluster-ceab:~$ screen -ls There is a screen on: 14868.pruebaScreen (13/06/17 09:48:18) (Detached) 1 Socket in /var/run/screen/S-miguel.omullony.

and then:

miguel.omullony@cluster-ceab:~$ screen -r 14868

Now consider this. If we see (Attached) when we list the screen sessions we will not be able to reattach to that session directly.

There are two ways to reattach an attached session:

screen -d <screen.id>
screen -r <screen.id>

or

screen -d -r <screen.id>
  1. When the program has ended and we want to close the screen session. First close the program if it's opened. Then exit the node to close the qlogin and finally exit again to close the screen session
miguel.omullony@node108:~$ exit
logout
miguel.omullony@cluster-ceab:~$ exit

#again it's like use the command clear

If I press up key:

miguel.omullony@cluster-ceab:~$ screen -d -r 14868 # last command I used before I reattached to the screen session
[screen is terminating]
miguel.omullony@cluster-ceab:~$

This is an example. I will use this to indicate our terminal '——— N' ; and this '———- S' means the screen terminal:

---------------------------------------------- N
miguel.omullony@cluster-ceab:~$ screen -S hola 
---------------------------------------------- S
miguel.omullony@cluster-ceab:~$ screen -d
[18033.hola detached.]
---------------------------------------------- N
[remote detached from 18033.hola]
miguel.omullony@cluster-ceab:~$ screen -ls
There is a screen on:
	18033.hola	(13/06/17 10:32:42)	(Detached)
1 Socket in /var/run/screen/S-miguel.omullony.

miguel.omullony@cluster-ceab:~$ screen -r hola
--------------------------------------------------------------- S
miguel.omullony@cluster-ceab:~$ screen -ls
There is a screen on:
        18033.hola      (13/06/17 10:32:42)     (Attached)
1 Socket in /var/run/screen/S-miguel.omullony.

miguel.omullony@cluster-ceab:~$ qlogin
local configuration cluster-ceab not defined - using global configuration
Your job 46039 ("QLOGIN") has been submitted
waiting for interactive job to be scheduled ...
Your interactive job 46039 has been successfully scheduled.
Establishing builtin session to host node101 ...
groups: cannot find name for group ID 20232
miguel.omullony@node101:~$ screen -d
There is no screen to be detached.
miguel.omullony@node101:~$ screen -ls
No Sockets found in /var/run/screen/S-miguel.omullony.

miguel.omullony@node101:~$ exit
logout
miguel.omullony@cluster-ceab:~$ screen -ls
There is a screen on:
        18033.hola      (13/06/17 10:32:42)     (Attached)
1 Socket in /var/run/screen/S-miguel.omullony.

miguel.omullony@cluster-ceab:~$ screen -d -r hola
Attaching from inside of screen?         
miguel.omullony@cluster-ceab:~$ screen -d
[18033.hola detached.]
--------------------------------------------------------- N
[remote detached from 18033.hola]
miguel.omullony@cluster-ceab:~$ screen -ls
There is a screen on:
	18033.hola	(13/06/17 10:32:42)	(Detached)
1 Socket in /var/run/screen/S-miguel.omullony.

miguel.omullony@cluster-ceab:~$ 
guides.1528889080.txt.gz · Last modified: 2018/06/13 11:24 by xavi