#!/bin/bash # watch_and_nice - Watches for the specified process name, and renices it # to the desired value when seen. if test $Argc -ne 2 { echo "Usage: $[basename $0] desirednice jobname" > !2 exit 1 } setglobal pid = $[renicename -p $2] if test $pid == "" { echo "No process found for $2" exit 1 } if test ! -z $[echo $pid | sed 's/[0-9]*//g] { echo "Failed to make a unique match in the process table for $2" > !2 exit 1 } setglobal currentnice = $[ps -lp $pid | tail -1 | awk '{print $6}] if test $1 -gt $currentnice { echo "Adjusting priority of $2 to $1" renice $1 $pid } exit 0