Skip to content

Instantly share code, notes, and snippets.

@Avyd
Last active January 2, 2016 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Avyd/8285906 to your computer and use it in GitHub Desktop.
Save Avyd/8285906 to your computer and use it in GitHub Desktop.
CPU Heat Keeper
#!/bin/bash
echo "CPU Heat-keeper"
echo "---------------"
echo "Required - sensors and cpuburn"
echo "Tested on 3rd gen i5 procs."
echo "Use at your own risk!"
echo ""
# ---- Settings ----
maxheat=80
midheat=74
minheat=68
sleep=5
# ---- /Settings ----
# ---- Script ----
while true
do
date=$(date +%H:%M:%S)
curheat=$(sensors | grep "Core 0:" | cut -c 18-19)
run1=$(ps aux | grep burnMMX | grep -v grep | wc -l)
run2=$(ps aux | grep burnBX | grep -v grep |wc -l)
run=$((${run1} + ${run2}))
echo "$date - Current heat is $curheat"
# if burner is not running, move on
if [ $run -eq 0 ]; then
echo "Checking current heat."
# if minheat < curheat burnMMX, burnBX
if [ $curheat -lt $minheat ]
then
echo "Starting burnMMX."
burnMMX &
echo "Starting burnBX"
burnBX &
fi
else
echo "Burner running!"
fi
# if midheat is more than needed - kill burnBX
if [ $curheat -gt $midheat ]
then
echo "Killing burnBX.."
kill -9 `ps a | grep burnBX | grep -v "grep" | cut -d " " -f 1,2` > /dev/null 2>&1
fi
# if maxheat is more than should be - kill MMX also
if [ $curheat -gt $maxheat ]
then
echo "Killing burnMMX.."
kill -9 `ps a | grep burnMMX | grep -v "grep" | cut -d " " -f 1,2` > /dev/null 2>&1
fi
sleep $sleep
done
# ---- /Script ----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment