Hey linux friends,
I have a small 'server' at home that I use primarily as an NFS/webcache/seedbox/toy.
I also run boinc as it spends most of its time fairly idle. It has an intel core 2 duo and I set boinc to use 1 core. So as to keep it responsive i wrote a script to monitor its 5 minute load average and suspend boinc if it goes above 1.5 and resume it if it falls below this.
Code:
#!/bin/bash
log=/var/log/loadWatchDog
date >> $log; echo "Beggining scrpt" >> $log
threshold=1.49
last=""
while [ 1 ]; do
sleep 5m
loadavg=`uptime | awk '{print $10}'| awk -F \, '{print $1}'`
result=`expr $loadavg \> $threshold`
if [[ "$result" -eq "1" ]] && [[ $last != "off" ]] ; then
date >> $log; echo "stopping" >> $log
boinccmd --set_run_mode never
last="off"
fi
result=`expr $threshold \> $loadavg`
if [[ "$result" -eq "1" ]] && [[ $last != "on" ]]; then
date >> $log; echo "starting" >> $log
boinccmd --set_run_mode always
last="on"
fi
done
exit 0
and i set it to run at startup by copying it into the /etc/init.d/ directory and running
Code:
sudo update-rc.d loadWatchDog.sh defaults
When it is powered on and pluged into a monitor it shows the starting services but seems to get stuck at starting boinc (squid also appears to not be running) never reaching the login prompt, i can however ssh in. This problem goes away when i remove my script.
Anyone have any ideas what i've done wrong?
Bookmarks