"flush" script: Wait until no jobs are running

Here's a small script I wrote to wait until no jobs are running in Workload Scheduler.

#!/bin/bash
# Where is conman?
conman=/opt/IBM/TWA/TWS/bin/conman
# Set the fence so no more jobs start
$conman 'fence @;go;noask'
# Poll for running jobs
running=$($conman 'sj @#@.@+state=exec,wait;keys' 2>/dev/null | grep -v '^%' | wc -l)
echo -n "Jobs running: "
while [ $running -gt 0 ]
do
  echo -n "$running "
  sleep 4
  running=$($conman 'sj @#@.@+state=exec,wait;keys' 2>/dev/null | grep -v '^%' | wc -l)
done
echo "Done."

Room for improvement

If I improve this script, I will add the capability to pass one or more workstation names as arguments for the script to watch, and to have its default be the "local" workstation.

 

 

 

Tags: