Created
September 2, 2025 08:32
-
-
Save pordyna/e0b15e8254f9d05cef7dd8cf18e9e410 to your computer and use it in GitHub Desktop.
tail job output for all running slurm jobbs (assuming output is written to a file called stdout)
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 | |
| jobs=$(squeue -u $USER --noheader --format="%A") | |
| for jobid in $jobs; do | |
| job_info=$(scontrol show job $jobid) | |
| workdir=$(echo "$job_info" | grep -oP 'WorkDir=\K\S*') | |
| stdout_file=$(echo "$job_info" | grep -oP 'StdOut=\K\S*') | |
| [ -z "$workdir" ] && workdir="." | |
| [ -z "$stdout_file" ] && stdout_file="slurm-${jobid}.out" | |
| echo "========================================" | |
| echo "JobID: $jobid" | |
| echo "WorkDir: $workdir" | |
| echo "StdOut: $stdout_file" | |
| echo "----------------------------------------" | |
| # Improved path logic | |
| if [[ "$stdout_file" = /* ]]; then | |
| outfile="$stdout_file" | |
| else | |
| outfile="$workdir/$stdout_file" | |
| fi | |
| if [ -f "$outfile" ]; then | |
| tail "$outfile" | |
| else | |
| echo "No output file found at $outfile." | |
| fi | |
| echo "" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment