Skip to content

How to wrap your submission script

This is a simple example of how to wrap a submission script to use script or bash variables for submission parameters such as output or jobname. Lets save the following file as executable script “jobwrap.bash”.

#!/bin/bash

if [[ $# -ne 2 ]]; then
    echo "$0 must be called with 2 parameters: command and input - exiting"
    exit 1
fi

RUN_CMD=$1
INPUT=$2

sbatch <<END_OF_SUBMISSIONSCRIPT
#!/bin/bash

#SBATCH --time=00:01:00
#SBATCH --output=${RUN_CMD}_$(basename ${INPUT}).out
#SBATCH --partition=dev
#SBATCH --job-name=${RUN_CMD}_${INPUT}
#SBATCH --ntasks=1

echo running ${RUN_CMD} ...

eval ${RUN_CMD} ${INPUT} 

END_OF_SUBMISSIONSCRIPT

Then simply launch the script for example by:

./jobwrap.bash "ls" "${HOME}/.config/"

When the job is done you will see the content of your “.config”-directory in ls_.config.out