Skip to content

Instantly share code, notes, and snippets.

@MVesuviusC
Created December 20, 2023 13:19
Show Gist options
  • Save MVesuviusC/3f3cf69a85510fa9c7453fb334b34bcb to your computer and use it in GitHub Desktop.
Save MVesuviusC/3f3cf69a85510fa9c7453fb334b34bcb to your computer and use it in GitHub Desktop.
slurm stuff
function sacctRun() {
sacct --format="user,jobid,jobname,node,state,ExitCode,start,end,maxrss" \
| grep -v "COMPLETE\|FAIL\|CANCEL\|OUT_OF_ME" \
| awk '$2 != "batch" && $2 != "extern" {print}'
}
get_maint_time () {
maint_start=$(scontrol show -u root reservation \
| perl -pe 's/\n/#/g' \
| perl -pe 's/#ReservationName=/\n/g' \
| grep MAINT \
| perl -ne '/.+StartTime=(.+)\sEndTime/; print $1;')
difftime=$(($(date +%s -d "$maint_start") - $(date +%s) - 1000))
req_len=$(date -d "@$difftime" "+$(($difftime/86400))-%H:%M:%S")
echo $req_len
}
alias salloc_l='salloc --time=$(get_maint_time)'
alias srun_l='srun --time=$(get_maint_time)'
scontrol update jobid=4350738,4350740 partition=himem,general
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment