[Bf-cycles] Pause
Kovacsics Róbert
kovirobi at gmail.com
Tue Jun 5 19:11:05 CEST 2012
Seems it did not like the attachment, so here it is:
#!/bin/bash -x
declare -a STOPPED_PIDS
temp=($(cat /sys/class/thermal/thermal_zone*/temp))
OLDIFS=$IFS
IFS="
"
for i in "${temp[@]}"; do
if [ "$i" -gt 95000 ]; then
cpu_hog=($(ps a -o pid --sort -cp | grep -v "PID"))
ps=$(echo ${cpu_hog[0]} | grep -o "^[[:space:]]*[[:digit:]]*")
STOPPED_PIDS[${#STOPPED_PIDS[@]}]=$ps
echo ${STOPPED_PIDS[@]}
kill -19 ${STOPPED_PIDS[@]}
/usr/bin/logger "Stopped ${STOPPED_PIDS[@]} because of high
CPU temperature"
( sleep 2m; kill -18 ${STOPPED_PIDS[@]}) &
sleep 5s
break;
fi
done
IFS=$OLDIFS
sleep 10s
exec $0
More information about the Bf-cycles
mailing list