-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsqueue
More file actions
executable file
·43 lines (39 loc) · 1.44 KB
/
Copy pathtsqueue
File metadata and controls
executable file
·43 lines (39 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -euo pipefail
# shellcheck disable=SC1091
source "$(dirname "$0")/tiny_sched_common.sh"
load_config
printf "%8s %-20s %-10s %6s %6s %s\n" JOBID NAME STATE CPUS TIME SUBMIT
print_dir() {
local dir=$1 state=$2 f
for f in "$dir"/*.meta; do
[ -f "$f" ] || continue
local jid name cpus submit start end now dur atid jid_disp shown_state
jid=$(meta_get "$f" job_id || echo 0)
name=$(meta_get "$f" job_name || echo job$jid)
cpus=$(meta_get "$f" req_cpus || echo 1)
submit=$(meta_get "$f" submit_ts || echo "")
start=$(meta_get "$f" start_time || echo "")
end=$(meta_get "$f" end_time || echo "")
now=$(date +%s)
dur=0
if [ -n "$start" ]; then
if [ -n "$end" ] && [ "$end" -gt 0 ]; then
dur=$(( end - start ))
else
dur=$(( now - start ))
fi
fi
atid=$(meta_get "$f" array_task_id || echo "")
if [ -n "$atid" ]; then jid_disp="${jid}_${atid}"; else jid_disp="$jid"; fi
shown_state=$state
# If meta file has explicit state (may have changed after directory move), prefer it
meta_state=$(meta_get "$f" state || echo "$state")
if [ -n "$meta_state" ]; then shown_state=$meta_state; fi
printf "%8s %-20s %-10s %6s %6s %s\n" "$jid_disp" "$name" "$shown_state" "$cpus" "$dur" "$submit"
done
}
print_dir "$TJS_PENDING_DIR" PENDING
print_dir "$TJS_RUNNING_DIR" RUNNING
print_dir "$TJS_COMPLETED_DIR" COMPLETED
print_dir "$TJS_FAILED_DIR" FAILED