Skip to main content
Startup scripts let you customize Slurm worker nodes, login nodes, and the controller by running shell scripts at node startup, job start, and job completion. Use them to install packages, prepare job environments, clean up after jobs, and append custom Slurm configuration. You can add scripts when you create a cluster and update them afterward.
Startup scripts work only on Slurm clusters that run Slinky v1.0. To check which version your cluster runs, see Slurm configuration.

Script types at a glance

Scripts fall into three categories based on when they run. Node init scripts run once when a node starts up:
  • Worker init script: Runs on each Slurm worker at boot. Install system packages, configure drivers, or pull container images.
  • Login init script: Runs on the login node at startup. Install CLI tools and packages for interactive SSH sessions.
Job lifecycle scripts run on every job allocation and completion:
  • Worker prolog: Runs on each worker node before a job starts. Set up directories, load datasets into local scratch, or export environment variables.
  • Worker epilog: Runs on each worker node after a job ends. Clean up scratch files, flush logs, or reset node state.
  • Controller prolog: Runs on the Slurm controller (slurmctld) at job allocation. Validate job parameters, send notifications, or log job metadata centrally.
  • Controller epilog: Runs on the Slurm controller (slurmctld) at job completion. Log results, trigger downstream pipelines, or send completion notifications.
Extra configuration is not a script but a raw config block:
  • Extra slurm.conf: Custom lines appended to slurm.conf on all nodes. Use this for scheduler tuning, prolog flags, or partition overrides.

Node init scripts

Worker init script

Runs on each Slurm worker node at boot, before the node accepts jobs. Use it to install packages or configure the environment that all jobs on this node depend on. Common use cases:
  • Install system packages (apt-get install -y sox ffmpeg).
  • Install the AWS CLI or other data-transfer tools.
  • Pull container images or download shared assets.
  • Configure environment variables that apply to every job.
Example:

Login init script

Runs on the login node at startup. The login node is where users SSH in to submit jobs and inspect results, so this script installs tools for interactive use. Common use cases:
  • Install CLI utilities for data exploration.
  • Set up shared Python environments.
  • Configure shell defaults for all users.
Example:

Job lifecycle scripts

Worker prolog

Runs as root on each allocated worker node before any user processes launch. Common use cases:
  • Create per-job scratch directories on local NVMe.
  • Stage input data from shared storage to local disk.
  • Export environment variables for the job.
  • Verify GPU health before the job runs.
Example:
The worker prolog runs when the job is allocated, because the cluster’s default PrologFlags=Contain implies Alloc. A PrologFlags line in Extra slurm.conf replaces that default rather than adding to it, so keep Contain in yours (for example, PrologFlags=Alloc,Contain).

Worker epilog

Runs on each allocated worker node after the job ends. The script runs as root and executes after all user processes have terminated. Common use cases:
  • Remove per-job scratch directories.
  • Flush job logs to shared storage.
  • Reset GPU state or clear shared memory.
  • Kill orphaned processes.
Example:

Controller prolog

Runs on the Slurm controller (slurmctld) at job allocation, before the job reaches the worker nodes. Use this for centralized setup that does not need to run on every node. Common use cases:
  • Log job metadata to a central database.
  • Send a Slack or webhook notification when a job starts.
  • Validate job parameters before workers are assigned.
Example:

Controller epilog

Runs on the Slurm controller (slurmctld) at job completion. Use this for centralized teardown or post-job automation. Common use cases:
  • Log job completion and exit status.
  • Trigger a downstream pipeline (fine-tuning, evaluation, deployment).
  • Send a completion notification.
Example:

Extra slurm.conf

Adds your lines verbatim to slurm.conf on all nodes, after the default configuration. Common use cases:
  • Add partitions or raise limits such as MaxArraySize.
  • Tune scheduler parameters.
  • Configure accounting or job completion plugins.
Example:

View configured startup scripts

Configured scripts appear on the cluster details page as .sh files (and extra_slurm.conf for the extra configuration block). Select a file name to open a read-only dialog with the script contents and a copy button.

Add startup scripts to a new cluster

  1. On the GPU clusters page, select Create cluster and set Orchestration to Slurm.
  2. Under Cluster add-ons, set Startup Scripts to Yes. The text boxes below the toggle become editable.
  3. Enter each script you need in its text box (Worker Prolog, Worker Epilog, Login Init Script, Worker Init Script, Extra slurm.conf, Controller Prolog, or Controller Epilog). Each script can be up to 64 KB. Every script except Extra slurm.conf must start with #!/bin/bash, #!/usr/bin/env bash, #!/bin/sh, or #!/usr/bin/env sh.
  4. Complete the rest of the form, select Create Cluster, and then select Confirm & Create.

Update startup scripts on an existing cluster

To update scripts in the console:
  1. On the cluster details page, select Edit Configuration.
  2. Change the scripts, and then select Save.
To update scripts from code instead, pass them in cluster_config.slurm_startup_scripts to the cluster update API. The API also requires cluster_config.load_balancer in the same request. When a change takes effect depends on the script type:
  • Extra slurm.conf: Takes effect on the running cluster through a live scontrol reconfigure. Workers briefly re-register with the controller, but running jobs aren’t interrupted.
  • Prolog and epilog scripts: Take effect on a worker only when its pod restarts, because each worker fetches its scripts through Slurm’s configless mechanism at pod startup. Until then, new jobs on that worker keep using the old scripts, even though the underlying ConfigMaps update immediately. To apply the update without ending running jobs, drain the workers, wait for their jobs to finish, and then restart their pods with kubectl delete pods -n slurm -l app.kubernetes.io/name=slurmd.
  • Init scripts: Take effect the next time each worker or login pod starts or restarts, because init scripts run at pod startup.
In the console, clearing a prolog, epilog, or init script doesn’t remove it. The script keeps running until you recreate the cluster. Clearing Extra slurm.conf does remove your lines. The API ignores empty fields, so it can’t clear a script or Extra slurm.conf.

Failure handling

Script failures have different consequences depending on which script fails. Worker prolog failure (non-zero exit):
  • The node is set to DRAIN state.
  • The job is requeued (batch jobs only). Interactive jobs (salloc, srun) are cancelled.
Worker epilog failure (non-zero exit):
  • The node is set to DRAIN state.
  • A drained node does not accept new jobs until an admin resumes it.
Controller prolog failure (non-zero exit):
  • The job is requeued (batch jobs) or cancelled (interactive jobs).
  • The node is not affected.
Controller epilog failure (non-zero exit):
  • The failure is logged but has no other effect on the job or node.
A failing prolog or epilog on a worker node drains the node. Monitor your scripts carefully and test them before deploying to production clusters.

Best practices

  • Keep scripts short and fast, because long-running scripts delay job scheduling.
  • Use set -e in init scripts so the script stops at the first failed command instead of continuing silently.
  • Don’t call Slurm commands such as squeue, scontrol, or sacctmgr from prolog or epilog scripts. They can cause deadlocks and degrade scheduler performance.
  • Use the SLURM_JOB_ID and SLURM_JOB_USER environment variables to scope cleanup and logging to the correct job.

Troubleshooting

Node stuck in DRAIN state after script failure

A worker prolog or epilog that returns a non-zero exit code drains the node. Fix:
  1. Find the drained node with sinfo -R.
  2. Check that worker’s slurmd log (/var/log/slurm/slurmd.log) for the script’s error.
  3. Fix the script.
  4. As a project admin, resume the node from the login node:

Init script packages not available in jobs

The worker init script runs at node boot, not at job start. If the script’s package install fails silently, jobs on that node don’t have the expected tools. Fix:
  • SSH into a worker node and verify the package is installed.
  • Add set -e to your init script to catch failures.

Additional resources