• Zur Metanavigation
  • Zur Hauptnavigation
  • Zur Suche
  • Zum Inhalt
  • Zur Subnavigation
  • Zum Seitenfuß
  • University of Hamburg
  • For journalists
  • Staff Service Portal0
  • STiNE
https://www.kus.uni-hamburg.de/aktuelles.json?recentnews=true
  • Institutions and target groups
    • Einrichtungen
      • Faculties

        • Faculty of Law
        • Faculty of Business, Economics and Social Sciences
        • Faculty of Medicine
        • Faculty of Education
        • Faculty of Humanities
        • Faculty of Mathematics, Informatics and Natural Sciences
        • Faculty of Psychology and Human Movement Science
        • University of Hamburg Business School
      • Services

        • Study Information Net STiNE
        • Surfmail
        • Exchange
        • Staff Service Portal
        • Learning Platforms
        • Katalogplus – Catalogue of Hamburg Libraries
        • SharePoint
      • Student facilities and services

        • Campus Center
        • Career Center
        • PIASTA
        • AStA (student council)
        • University Sports
        • University Music
        • Family Office
        • University Language Center
        • General Languages
        • Office of Affairs for Students with Disabilities or Chronic Diseases
        • Departmental libraries
        • Healthy Campus
      • Further facilities and services

        • The Cluster of Excellence CLICCS
        • The Cluster of Excellence CUI
        • The Cluster of Excellence Quantum Universe
        • The Cluster of Excellence Understanding Written Artefacts
        • Hamburg Research Academy
        • Pier Plus
        • Hamburg Center for University Teaching and Learning (HUL)
        • Hub for Crossdisciplinary Learning (HCL)
        • CEN
        • Museums and collections
        • University Archives (in German)
        • Regional Computing Center (RRZ)
        • University Administration
        • Knowledge Exchange Agency
        • The Unikontor Shop (in German)
    • Target groups

      • Prospective students
      • Students
      • International prospective students
      • Young researchers
      • Researchers
      • Instructors
      • Staff
      • Prospective continuing education students
      • Alumni
      • Journalists
      • Refugees (in German only)
    Close
  • /en/sitemap.json
University of Hamburg - to research, to teach, to educate and form, to homepage

RRZ

Regional Data Center
(RRZ)
  • Support
    • RRZ-ServiceLine/STiNE-Line
    • RRZ-ServiceDesk
    • RRZ-ServicePortal
    • RRZ Feedback
    • RRZ Portfolio
    • Application Forms
    • Instructions/Glossary
    • FAQ
    • Policies
    • Support Forms
  • Services
  • ID & Authentication
    • Apply for an identifier
    • Forgotten/change password
    • Set up two-factor authentication
    • Managing identifier groups (group manager)
  • Innovation
    • Research & Education
    • Organisational Development
  • About Us
    • RRZ News
    • Mission statement
    • Map / Directions
    • Operating Hours / Opening Hours
    • RRZ Staff
    • Careers
    • Organizational Structure
    • Webinars
    • Equal Opportunity at the RRZ
    • History of the RRZ

Photo: Thomas Orgis

  1. UHH
  2. RRZ
  3. Services
  4. HPC
  5. Hummel-2
  6. batch
  7. examples
  8. structure

Generic structure of a (Slurm) batch job

A batch job is a shell script that is processed by a batch system. A typical batch job is shown below. It has four sections

  1. shebang (line 1)
  2. submit options (lines 3–5)
  3. initialization (lines 8–9)
  4. data handling and work (lines 12–15)
that are explained afterwards. The example shows the basic structure. Real batch jobs can become more complex.

line
no.
batch job structure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# submit options
#SBATCH --ntasks=1
#SBATCH --time=00:05:00
#SBATCH --export=NONE

# initialization
source /sw/batch/init.sh
module load package/version

# data handling and work
cd /path/to/working/directory             # optional, see Explanations
cp /path/to/input/directory/input.dat .   # optional, see Explanations
binary [arguments]
cp output.dat /path/to/output/directory/  # optional, see Explanations

exit

Explanations

1. shebang

  • The first line of every shell script is the Shebang which specifies the command line interpreter to use.

2. submit options

  • In a batch job the next lines contain submit options. Alternatively options could be given as arguments to the submit command. The syntax for specifying options is the same in both cases. In a job script submit options must be preceded by a special prefix which is #SBATCH for the SLURM batch system. Syntactically the first character of the prefix makes such a line a shell script comment. The submit command stops processing these lines once the first line containing a shell command has been reached.
  • We recommend to always set --export=NONE in order to begin each job with a known environment. The reason is reproducibility. The default behaviour is that a job inherits ALL environment variable settings that exist at submit time. Environment variable settings can influence performance and even results. Therefore, we consider it to be good practice to exclude side effects that might be introduced by inheritance of environment variables. (For completeness it should be mentioned that the batch system sets the environment variable SLURM_EXPORT_ENV at execution time if --export=NONE was set at submit time. In particular for MPI programs it turned out that one should unset SLURM_EXPORT_ENV in the script if --export=NONE was specified. At RRZ one does not have to care about removing SLURM_EXPORT_ENV because this is done in /sw/batch/init.sh.)
  • Submit options are described in the man-page of the sbatch command.

3. initialization

  • System specific initialization. It depends on the system whether system specific initialization is needed. For example, on our system source /sw/batch/init.sh provides temporary directories and the module function which is often needed in job specific initialization.
  • Job specific initialization. There are two typical use cases:
    • For application packages the corresponding module must be loaded.
    • For self-compiled software it might be necessary to load (or switch to) exactly the same modules that were loaded at compile time. For MPI programs that are lauched with mpirun command the MPI module used at compile time must be loaded in any case.

4. data handling and work

This part contains commands for handling data and the actual work to be performed. Usually one would avoid any unnecessary data movement. However, changing the working directory and copying data is included here in order to mention its relevance for I/O performance which is likely to become a bottleneck in data-intensive jobs.
  • Selecting the working directory. The default working directory is the directory in which the submit command was issued. In particular for data-intensive jobs it should be checked whether using local SSDs is advantageous, which have the best I/O performance of all disk system in the cluster. SSDs can be used by cd-ing to $RRZ_LOCAL_TMPDIR .
  • Copying data in. In particular when local disks are used data needs to be copied there before it can be used.
  • Work. In many cases the work to be performed can be specified in a single command.
  • Copying data out / saving data. In particular when local disks are used results need to be saved to other disks (because data on the local disks will automatically removed at the end of a job).
  • getting access
  • quick start
  • migration from Hummel
  • hardware
  • working with data
  • software
  • running batch jobs
    • example batch jobs
      • batch job structure
        • first test jobs
        • std partition
        • big partition
        • gpu partition
        • batch jobs with jobber
      • job chains
    • RRZ tools
    • acknowledgements

    Last update: 7 September 2024

    • Feedback
    • Legal notice
    • Privacy statement
    • Accessibility
    • Site map

    University of Hamburg

    Innovating and Cooperating for a Sustainable Future in a Digital Age

    • Follow us on Instagram.
    • Follow us on Facebook.
    • Connect with us on LinkedIn.
    • Follow us on Mastodon.
    • Follow us on Bluesky.
    • Subscribe to our channel on YouTube.
      • Studies
      • Prospective students
      • Continuing education
      • Research
      • Teaching at UHH
      • Doctoral studies
      • Job opportunities
      • Knowledge exchange
      • University
      • Excellence
      • Faculties
      • Alumni
      • Contact
      • Campus Navigator
      • UHHApp
      • Emergencies, safety and security
      • Antidiscrimination
    Go to family-friendly higher education institution audit
    Go to internationalisation re-audit
    Go to the Sustainability Audit page
    Go to Diversity Audit
    Go to System accreditation

    © 2026 University of Hamburg. All rights reserved