Created
January 23, 2026 15:57
-
-
Save allain/ba36ebefbcbaef6888f5d9454e7ceeaf to your computer and use it in GitHub Desktop.
restart all jobs in a nomad cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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