Last active
May 2, 2019 02:47
-
-
Save victorhcm/bec1ae97d6d7e54e75ee381c58783635 to your computer and use it in GitHub Desktop.
SLURM utils. Add to your .bashrc
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
# ================================================= | |
# SLURM UTILS | |
# ================================================= | |
# sbatlog: runs sbatch and automatically tail -f slurm-$number.out | |
function sbatlog | |
{ | |
result=$(command sbatch "$@") | |
outputid=$(echo $result | awk -F' ' '{print $NF}') | |
# fileout="slurm-$outputid.out" # assumes default file output name | |
fileout="$2" # assuming that $2 is the argument for -o FIXME | |
fileout=$(echo $fileout | sed "s:%j:$outputid:g") | |
# wait file to be created | |
echo "Watching file $fileout" | |
while [ ! -f $fileout ] | |
do | |
sleep 1 | |
done | |
printf "\033c" # clears screen | |
tail -f $fileout | |
} | |
# slastlog: opens last created slurm-<pid>.out log with less | |
function slastlog | |
{ | |
last_log="$(ls -lat ./slurm-*.out | head -1 | awk '{print $NF}')" | |
echo "Opening $last_log" | |
less "$last_log" | |
} | |
# slastlog: opens last created slurm-<pid>.out log with tail | |
function stail | |
{ | |
last_log="$(ls -lat ./slurm-*.out | head -1 | awk '{print $NF}')" | |
echo "Opening $last_log" | |
command tail -f "$last_log" | |
} | |
# sgrep: greps the last log file | |
function sgrep | |
{ | |
last_log="$(ls -lat ./slurm-*.out | head -1 | awk '{print $NF}')" | |
echo "grepping $last_log" | |
command grep "$@" "$last_log" | command less | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment