X BOL wishing you a very and Happy New year

Alternative content

Keep Your Important SSH Session Running when You Disconnect from Server !!!

As a Bioinformatician/ Computational biologist we swim in the ocean of genomic/proteomics data, and play with them with an ease. In our day to day simulation, analysis, comparative study we do need to run exhaustive programs, which might take more than a week. In such cases we do need to disconnect from sever in a way that our program/session should not get terminated. To do so there are lots of software, tools such as tmux ( http://tmux.sourceforge.net/, nohup (http://ss64.com/bash/nohup.html) , byobu (https://help.ubuntu.com/10.04/serverguide/byobu.html) and other commands (disown -a && exit), but following are the ones I use the most.

Screen is like a window manager for your console. It will allow you to keep multiple terminal sessions running and easily switch between them. It also protects you from disconnection, because the screen session doesn’t end when you get disconnected.

You’ll need to make sure that screen is installed on the server you are connecting to. If that server is Ubuntu or Debian, just use this command:

sudo apt-get install screen

Now you can start a new screen session by just typing screen at the command line. You’ll be shown some information about screen. Hit enter, and you’ll be at a normal prompt.

To disconnect (but leave the session running)

Hit Ctrl + A and then Ctrl + D in immediate succession. You will see the message [detached]

To reconnect to an already running session

screen -r

To reconnect to an existing session, or create a new one if none exists

screen -D -r

To create a new window inside of a running screen session

Hit Ctrl + A and then C in immediate succession. You will see a new prompt.

To switch from one screen window to another

Hit Ctrl + A and then Ctrl + A in immediate succession.

To list open screen windows

Hit Ctrl + A and then W in immediate succession

Comments

  • Rahul Nayak 3683 days ago

    I notice, you forgot to mention following useful comman in this nice tutorial:

    killall -15 screen

    or

    pkill -15 screen  

    ------> to kill all running screens !!!

  • Jitendra Narayan 3679 days ago

    Kill Attached Screen in Linux

    screen -X -S SCREENID kill

    alternatively, you can use the following command

    screen -S SCREENNAME -p 0 -X quit

    You can view the list of the screen sessions by executing screen -ls

  • Rahul Nayak 3671 days ago

    Wipe out the dead screen with "screen -wipe" command

  • BioStar 167 days ago

    To block a node 

    srun --partition=compute --nodes=1 --ntasks-per-node=40 --pty bash.sh