Skip to content

Instantly share code, notes, and snippets.

@naufalso
Created January 14, 2026 08:47
Show Gist options
  • Select an option

  • Save naufalso/fde6ecdd5ad8bf61eb2ec027f40ecec4 to your computer and use it in GitHub Desktop.

Select an option

Save naufalso/fde6ecdd5ad8bf61eb2ec027f40ecec4 to your computer and use it in GitHub Desktop.
Run sbatch with logs located in logs/[current-date]
#!/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