You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.1 KiB
67 lines
1.1 KiB
#!/bin/bash
|
|
#
|
|
# Extended squeue wrapper
|
|
#
|
|
# Wirawan Purwanto
|
|
# Created: 20180720
|
|
|
|
shopt -s extglob
|
|
set -e
|
|
|
|
optAllUsers=0
|
|
optHasUsers=0
|
|
optHasFormat=0
|
|
optSlurmFlags=()
|
|
|
|
FORMAT_DEFAULT="%.18i %.9P %.20j %.9u %.2t %.12M %.12l %.5D %R"
|
|
|
|
function ParseArgs()
|
|
{
|
|
local i
|
|
local nopass
|
|
|
|
local args args_count arg
|
|
args=( "zeroth-arg-not-used" "$@" )
|
|
args_count=$#
|
|
for ((i = 1; i <= args_count; ++i)); do
|
|
arg="${!i}"
|
|
case "$arg" in
|
|
# This script's options
|
|
(+a)
|
|
optAllUsers=1
|
|
;;
|
|
(+*)
|
|
: # ignore
|
|
;;
|
|
(-*|*)
|
|
optSlurmFlags[ ${#optSlurmFlags[@]} ]="$arg"
|
|
case "$arg" in
|
|
(-u*|--user?(=*))
|
|
optHasUsers=1
|
|
;;
|
|
(-l|-s|--long|--steps|-o|--format?(=*))
|
|
optHasFormat=1
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
function do_squeue()
|
|
{
|
|
# My old default is to show jobs for me only:
|
|
if ! (( optHasUsers || optAllUsers )); then
|
|
optSlurmFlags=( "${optSlurmFlags[@]}" -u "$USER" )
|
|
fi
|
|
if ! (( optHasFormat )); then
|
|
optSlurmFlags=( "${optSlurmFlags[@]}" -o "$FORMAT_DEFAULT" )
|
|
fi
|
|
squeue "${optSlurmFlags[@]}"
|
|
}
|
|
|
|
|
|
ParseArgs "$@"
|
|
do_squeue
|
|
|
|
|
|
|