Created
January 14, 2026 08:47
-
-
Save naufalso/fde6ecdd5ad8bf61eb2ec027f40ecec4 to your computer and use it in GitHub Desktop.
Run sbatch with logs located in logs/[current-date]
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 | |
| sbatch_logs() { | |
| if [ -z "$1" ]; then | |
| echo "Usage: run_sbatch <script.sbatch> [additional sbatch args]" | |
| return 1 | |
| fi | |
| local date_dir | |
| date_dir=$(date +%y%m%d) | |
| local log_dir="./logs/${date_dir}" | |
| # Create directory if it does not exist | |
| mkdir -p "$log_dir" | |
| sbatch \ | |
| --output="${log_dir}/%x-%j.out" \ | |
| --error="${log_dir}/%x-%j.err" \ | |
| "$@" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment