Main Navigation

Secondary Navigation

Page Contents

Contents

Submission of Shell Scripts or Commands

The UNIX command hostname returns the name of a node. The simplest way to execute a shell script or command is illustrated in the following example that returns the name of the executing node:

sbatch --wrap "hostname"
In case of your own shell script you have to add the execution path, like in ./my_script.sh.

If you script is a bit more complicated than that, you may collect your shell commands in a file, t.ex. my_script.sh, and add certain SBATCH options to it:

#!/bin/bash
#SBATCH -p you_project 		# select a project or insert # in first column 
#SBATCH -t 0:20                 # 20 seconds should be enough
#SBATCH --mail-type=END		# want a mail notification at end of job
#SBATCH -J jobname		# name of the job 
#SBATCH -o jobname.%j.out	# Output: %j expands to jobid
#SBATCH -e jobname.%j.err	# Error: %j expands to jobid
#SBATCH -C XEON_SP_6126		# selects only nodes of that type
#SBATCH -n 1			# single task

HOST=`hostname`
echo "This is an example for a batch script. Slurm scheduled it on node $HOST"

echo "I am interested of all environment variables Slurm adds:"
env | grep -i slurm

This shell script may then be submitted:

sbatch my_script.sh