Last active
June 15, 2023 17:02
-
-
Save drscotthawley/570a4aaa0dc1f7c67b8a4f2c422cd883 to your computer and use it in GitHub Desktop.
bash aliases for SLURM: "tailjob <jobid>" or just "tailtop" for most recent job
This file contains 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
# tails output of any SLURM job that is listed in the queue. | |
# if job is pending, tailjob will wait until the output file exists | |
# usage: tailjob <job_id> | |
tailjob() { | |
local job_id=$1 | |
if [[ -n "$job_id" ]]; then | |
local stdout_file=$(scontrol show job "$job_id" | awk -F= '/StdOut=/{print $2}') | |
echo "Running tail -F $stdout_file" | |
tail -F "$stdout_file" | |
else | |
echo "No job ID provided." | |
fi | |
} | |
# tails the output of your most recent SLURM job in the queue (i.e. top of your squeue -u list) | |
# usage: just "tailtop" with no arguments | |
tailtop() { | |
local job_id=$(squeue -u "$USER" --format="%A %i" --noheader | sort -k2 -n | awk 'END{print $1}') | |
tailjob "$job_id" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment