> I don't know if he was aware of this problem, but
> finally I had to obey because he insisted that
> his machine runs slower if mprime runs on it,
> and that it doesn't matter if other users agree to let
> me run mprime on their machines, 
> while he as the administrator forbids it.

I use teh script below on some Linux-boxes.  It checks every 30 seconds if 
there are any active users on the computer, execpt the ones i $USRS, which 
are users who have accepted that the program runs when they are active.  
Secondly it checks the load on the computer (5 minute average).  If there 
are any active users (active during the last ten minutes) or the load goes 
above $MAXL, then mprime is killed.  If the load goes back under $STAL and 
no user (except $USRS) have been active during the last ten minutes, then 
mprime is started again. 

------8<------ The script ------8<------
#!/bin/sh

WDIR="$HOME/mers/`hostname`"
PROG="$HOME/bin/linux/mprime"
MAXL="150"
STAL="10"
LOAD="0"
USRS="sturles |sturle "

export WDIR STAL LOAD USRS MPID

while :; do
STOP=`w | egrep -v "$USRS|[89m]( [1-5].:.. |...(d|:..m))|verage|^USER" | wc -l`
LOAD="`uptime | sed 's/^.*age:......//; s/\.//; s/,.*$//; s/[ 0]*//'`"
test -z "$LOAD" && LOAD="0"
if [ $STOP -gt 0 ] || [ $LOAD -gt $MAXL ]; then
   test -n "$MPID" && kill $MPID && MPID=""
else
   if [ -z "$MPID" ] && [ $LOAD -le $STAL ]; then
      $PROG -W$WDIR &
      MPID=$!
   fi
fi
sleep 30
done


-- 
Sturle    URL: http://www.stud.ifi.uio.no/~sturles/    Er det m}ndag i dag?
~~~~~~    OBS! Nytt PS-nummer: 965 04242 (PS-tekst)              - St. URLe

Reply via email to