Skip to content

Your first login on a cluster

preparations

Take a look on basic cluster documentation and try to make familiar with some basic gnu-commands.

identify/change your standard login-shell

Most of our examples are written for bash, as are most examples you find on the www; in contrast, university accounts older than August 2022 have tcsh set as the default login shell.

How to check or change my login shell

To identify or change your login shell you first have to login at ubt selfservice portal: startpage_1

Now navigate to “MY INFORMATIONS”>”Profile”: navigate_1

In your profile settings look for “Loginshell”: profile_1 If bash or zsh is set as your loginshell you could simply exit by “cancel” and then log out. If not its recommend to change login shell to bash or zsh and then apply changes by clickSAVE CHANGES”.

login on a cluster

If you have opened a terminal or console-app you just simply need to type:

ssh bt000000@emil.rz.uni-bayreuth.de

to login on one of emils login-nodes. bt000000 has to be replaced by your personal userid.

transfer data

For this example you first have to create a textfile named ‘myfile.txt’ on your local computer and use your terminal app to navigate the place where the file is stored.

To transfer the file from your local computer to the home directory of the cluster you could use:

scp myfile.txt bt000000@emil.rz.uni-bayreuth.de:/home/xy/bt0000xy
where ‘bt000000’ has to be replaced by your university-account and xy are the last 2 digits of your university account.

To transfer a file from the cluster to your local computer:

scp bt0000xy@btrzx1-1.rz.uni-bayreuth.de:/home/xy/bt0000xy/myfile.txt myfile.txt

If you want to transfer directories you have to use the ‘-r’ option of scp; so scp ... becomes scp -r ...

Experienced linux users are recommended to use rsync instead of scp. Rsync has more advanced sync options and ist usually faster than scp.

submit your first job

To submit your first job you need a job-script respectively submission-script first:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/bin/bash
#SBATCH --job-name="hello"
#SBATCH --nodes=1
#SBATCH --mail-type=END,FAIL
#SBATCH --mail-user=bt000000@uni-bayreuth.de
#SBATCH --time=0-00:00:10
#SBATCH --error=%x_%j.err
#SBATCH --output=%x_%j.out

echo "Hello $USER, my name is $HOSTNAME."
>&2 echo "This is an example error message from $HOSTNAME"
echo
echo "Well done $USER you submitted your first job!"

First save this script somewhere into your $HOME on the cluster under the name “1_hello” then submit your first job by:

sbatch ./1_hello

Now, depending on cluster workload, a few seconds/minutes later should be two new files in the directory where you submitted the job and you should receive a mail to your university mail account. The first file should be something like “hello_.err” this the file where errors are saved, look into it with:

cat ./hello_<somenumbers>.err

The second file should be named almost the same but ending with “.out” instead “.err”, look into it the same way as shown above. This is the file where the normal output gets stored.

Congrat! You submitted your first job!

Line by line explanation

Now lets look what it is about with this script line by line:

#!/bin/bash
This tells the slurm resource manager which shell it has to use, bash in this case.

#SBATCH --job-name="hello"
This defines the name of our job. For real life purposes it is recommend to give a brief but non generic name; instead of naming by program or algorithm we recommend to it by parameter sets.

#SBATCH --nodes=1
Here we specify how many nodes we need for job; one node is enough to say hello.

#SBATCH --mail-user=bt000000@uni-bayreuth.de
This tells slurm where mails have send to.

#SBATCH --mail-type=END,FAIL
We set the mail type in a way that slurm sends us a mail if the job is done or failed. That a job doesn’t fail does not have to mean that there are no errors.

#SBATCH --time=0-00:00:30
We tell the resource manager how long the job should take by D-HH:MM:ss. Try to be precise as possible here, the longer the time you specify the less your jobpriority gets and you have to wait longer for job to start. But if you set the time to short slurm will kill your job without chance for it to finish properly.

#SBATCH --error=%x_%j.err
This is how we name the file where errors get stored. The %x gets replaced by the jobname you choose and the %j will replace by the jobid (consecutive number).

#SBATCH --output=%x_%j.out
Pretty same like above option but for normal outputs.

echo "Hello $USER, my name is $HOSTNAME."
Our simple greeting message.

>&2 echo "This is an example error message from $HOSTNAME"
Echoing to error output, see the errorfile above.

echo

echo "Well done $USER you submitted your first job!"