Pular para o conteúdo principal
Base de Conhecimento da FocusVision

Using Unix Screen

  Requires Decipher Cloud

1:  Overview

Screen is a Unix program available on your private Decipher server. Screen allows you to run multiple shell sessions in the shell terminal. As a result, all shell sessions are running live on the server and if you disconnect from this session, it can be resumed by launching Screen again. You can also detach from the Screen session and resume it at another location. You’ll need standard SSH/sFTP access to your private server. We’ll be using Putty in our examples to SSH into the server.

2:  Using Screen

Type the below shell command to start your Screen session:

screen -dR

This shell command starts a new session if an existing one is not found (-dR stands for “Reattach) So the first time you run this, you will create a new session.  An existing session will be resumed.

3:  Useful Screen Commands  

While using Screen you will want to create multiple windows, switch between windows, and even kill a window.

The table below provides you with the most common Screen commands.

To execute a Screen command, you must prefix it with ctrl+a to prevent collision with content that you enter.

Screen Command Description
ctrl+a + c Create a new window
ctrl+a + ctrl+a Change to last-visited active window
ctrl+a + n Change to next window in list
ctrl+a + p Change to previous window in list
ctrl+a + <number> Change to a particular window number
ctrl+a + d Detach Screen session. Allows you to resume later.
ctrl+a + ' Change to window by number. Useful for 10+ windows
ctrl+a + " See window list (allows you to select a window to change to)
ctrl+a + k Kill current window (Use this for when your window freezes for whatever reason)
ctrl+a :number x Reassign window number, where x is a number.
ctrl+a + [ Allows you to scroll through your terminal window to see prior commands and messages.

4:  Use Cases:

The following provides common use cases for using Screen.

4.1:  Keeping Your Place

Let’s say you had 4 windows open, where each window represented a different project you were working on. You can simply leave these sessions open and go back to them when your project requires attention. No longer will you lose your place.

4.2: Preserving Your Work Without Saving

It’s a long night of programming. You don’t want to lose your place or your work. You don’t want to save any of your changes yet since you haven’t tested anything. Simply execute ctrl+a + d to detach your Screen session (or just close your window). When you log back into the shell terminal the next morning, type screen -dR to resume the session you left the night before.  You should start right back up where you left off with all windows intact.

4.3  Taking a Break and Resuming Your Work

Similar to 4.2, you are working on a project and you are doing some custom data merging or running simulated data for a large study. The timer says it’ll take 1+ hours to complete.  It’s 4:30pm and it’s about time to go home but you don’t want to stick around and wait for the script to finish or worse, start over after hours! Simply let Screen continue running the scripts while you go home. Once you are home, log back into the shell terminal with screen -dR to see where it’s at. No longer do you need to worry about internet connection disruptions or waiting for scripts to finish running. You can simply close your window and check back later.

5:  Common Issues with Screen:

The following are some common issues you may encounter while using Screen:

Your window may cut off your terminal text. Scrolling doesn’t work well given there’s multiple windows in Screen. Putty simply gets confused. In this case you can use ctrl+a + [ to scroll back up through the window to see your messages.

In rare instances your Screen windows may be lost. This ONLY happens if the server was rebooted. You will need to start up a new session using screen -dR.

It's possible that your Screen windows freeze, use ctrl+a + k to kill the window.

6:  Configuration File: .screenrc (Optional But Recommended)

A good .screenrc config file makes your Screen session more useful. There are many available ones online but our training team has supplied one that they use. Simply upload the following .screenrc file to your home directory (/home/user). This file has been fine tuned to show your current working directory at the top of your Putty terminal and inside your Screen session.  It also displays your current active window in green.

  • Este artigo foi útil?