Chapter 5 BASH
On this section we will write some hints on the Bourne Again Shell (BASH), a command interpreter used in several *nix systems, such as Linux, Unix, MacOS and recently incorporated into Windows through PowerShell. This will be more of a collection of hints, and not substituting a full knowledge of BASH and the Operating System in which is running.
5.1 Screen
Screen is a tool you can use to keep a ssh session run through BASH alive. Why it is useful(?):
- When you have unreliable internet connections connections (ex.: Wifi, cellphone);
- Power outages;
- Your local machine freezes, or have any other issue, and your connection is killed;
- Any random reason that blocks your local terminal to access the remote ssh session.
5.1.1 How to use it
Some useful description is available in this website, and on the app documentation. But you can proceed as follows:
5.1.3 See all available sessions
You probably will see something like this:
There are screens on:
6617.session_00 (09/26/2019 04:35:30 PM) (Detached)
1946.session_01 (09/26/2019 02:51:50 PM) (Detached)
2 Sockets in /run/screen/S-shs
5.2 Watch
Watch is a program that runs commands using a clock. In our case, watch is kind
of useful when needing to monitor an application shell output. Common cases in HPC
are when you need to see updates in nvidia-smi
or slurm squeue
command.
The base syntax is:
In which:
- XX is the refresh rate in seconds;
- command is the bash command you want to refresh the output