Skip to content

Instantly share code, notes, and snippets.

@allain
Created January 23, 2026 15:57
Show Gist options
  • Select an option

  • Save allain/ba36ebefbcbaef6888f5d9454e7ceeaf to your computer and use it in GitHub Desktop.

Select an option

Save allain/ba36ebefbcbaef6888f5d9454e7ceeaf to your computer and use it in GitHub Desktop.
restart all jobs in a nomad cluster
#!/bin/bash
# 1. Get list of Service and Batch jobs
# We skip the header line (NR>1) and grab the first column (Job ID)
JOBS=$(nomad job status -type service -type batch -short | awk 'NR>1 {print $1}')
# 2. Loop through and restart
for JOB in $JOBS; do
echo "Triggering rolling restart for: $JOB"
# The restart command respects the update stanza (canaries/health checks)
nomad job restart "$JOB"
# 3. Safety Sleep
# Give the scheduler a moment to evaluate placement for the new allocs
# before triggering the next one.
sleep 5
done
echo "All restart signals sent."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment