Tuesday, May 4, 2010

awk: kill all pimgr jobs in one go

Unfortunately, the /usr/local/pi/pimgr/bin/pimgr-jobs utility doesn't provide a "kill-all" option that automagically kills all the jobs that are currently scheduled to run.

Here's some simple scriptfoo that does the trick rather well:
for i in `gawk --re-interval '$1 ~ /^[0-9]{1,4}/ {print $1}' 1`
do 
./pimgr-jobs --jobid=$i  kill-delete
done


wrt this excellent link, plain old awk doesn't support braces/curlybrackets for denoting the number of occurrences. So you have to use gawk instead, with the '--re-interval' option as shown above. Whoa.


Powered by ScribeFire.