Skip to content

Tear free

Eamon O'Dea edited this page Nov 29, 2018 · 7 revisions

For those coming to the world of the command line and remote servers from the world of user-friendly graphical interfaces, there can be tears of pain that accompany the tears of joy that result from the discovery of new powers. The command line can seem to be a very inconvenient and unpleasant way to interact with a computer. However, many of the irritants that result from working on the command line can be avoided by using a few convenient tools or configuration options. This page collects those which are likely relevant to Drake lab members.

How to start a job that keeps running after you disconnect from the remote server

You can start a job that will keep running after you disconnect from the server by running the job in the background and ensuring that the hangup signal is blocked with nohup. For example, if you are using the bash shell (which is the default on the Drake lab computers) and have an R script called my-long-running-analysis.R in your current directory, you could start it like

nohup Rscript my-long-running-analysis.R &

The nohup part makes the command immune to hangups and the & puts the process which is executing the script into the background. In fact, the nohup part is not always needed as default settings often block the hangup signal, but is unlikely to hurt anything.

How to store SSH connection settings

Windows users using putty can store the IP address and hostname for a frequently used SSH server in a menu entry as described in the manual. Linux and Mac users using OpenSSH can achieve the same effect by creating an entry in the file at ~/.ssh/config. My work computer has the following entries:

Host monster
  Port 22
  Hostname 172.18.244.86
  user ebodea
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa

Host gradmonster
  Port 9922
  Hostname 172.18.244.88
  user ebodea
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa

Host croom
  User drakelab
  Hostname 172.18.244.94
  IdentityFile ~/.ssh/id_rsa

With this configuration, I can easily connect to the Drake lab computers using the shortcut names monster, gradmonster, and croom. For example, to connect to the high-memory machine OSE-WS148, I simply enter ssh gradmonster. No need to remember the nonstandard port number and the IP address! This example configuration can simply be pasted into your own computer's ~/.ssh/config, with the user ebodea changed to your own username, for you to avail yourself of this convenience. You may of course also want to choose less (or more) silly names for the shortcuts. Further details on the possible uses of .ssh/config are described in the ssh_config man page. One such detail is worth quoting here: "Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not accessible by others." Such permissions can be set by running the command chmod 600 ~/.ssh/config.

Rocker

Often, the most difficult part of a computational project is installing all of the software you need on the computer you want to run it on. The Docker project has developed a solution to this problem based on the idea of Linux containers. Containers are essentially lightweight virtual machines that allow a full computing environment to be easily transported from one computer to another. The Rocker project has developed a number of containers with lots of popular software for R users installed. They also provide a brief introduction on how to start using containers for your work, including how to use the containers with Rstudio. They even explain how to run Rstudio in a container on a node in a cluster. Careful study of the the Rocker website can certainly prevent many tears.

Lab Links

Clone this wiki locally