Skip to content

Instantly share code, notes, and snippets.

@zvakanaka
Created August 5, 2015 15:47
Show Gist options
  • Save zvakanaka/4fe1d63376976584416d to your computer and use it in GitHub Desktop.
Save zvakanaka/4fe1d63376976584416d to your computer and use it in GitHub Desktop.
SLEEPSECONDS=5
HOTPROC=ffmpeg
MAXHEAT=71
COOLDOWNTEMP=45
#TODO: ENSURE ONLY 1 PROCESS OF HOTPROC IS RUNNING
while pgrep $HOTPROC > /dev/null; do
sleep $SLEEPSECONDS
# getting temp of cpu
CORETEMP=$(sensors | grep 'Core 0')
CELCLINE=${CORETEMP#*+}
CELC=${CELCLINE%%\.0°C*}
if [ $CELC -gt $MAXHEAT ]; then
echo $CELC DEGREES, PAUSING $HOTPROC...
kill -STOP $(pgrep $HOTPROC)
elif [ $CELC -lt $COOLDOWNTEMP ]; then
echo Resuming $HOTPROC
kill -CONT $(pgrep $HOTPROC)
else
echo $CELC degrees celcius...
fi
done
@zvakanaka
Copy link
Author

apt-get install lm-sensors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment