Bitcoin Forum
June 22, 2018, 12:17:44 PM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: linux auto reboot bash script in case of gpu lock  (Read 3154 times)
Jr. Member
Offline Offline

Activity: 32
Merit: 0

View Profile
May 29, 2011, 04:41:20 AM

if you are like me and have set up a dedicated ubuntu as a mining machine (according to this post overclocked the gpu, you might experience gpu locked up at the middle of the night. It would be great if the system can autoboot in this case. It allows the gpu to run at the highest rate possible and only cost minimum if it freezes up.  This is my first linux bash script EVER, so please point out any errors.

The idea is to use the gpu temperature sensor to monitor the state. The normal calculation of GPU will probably result in GPU temperature rise to more than 40C (in my case, hd 5870). There should be a more elegant solution, but this is what i have now.

1. ATI graphical card, NVIDIA could too with a different command
2. Your computer could start mining at power up automatically.

use your favorite text editor and save it in your home directory as auto_reboot
start_script_time=300 #Wait time before the script start, computer start with 0 Celcius #wait 5min for temperature to rise
low_temp_threshold=40  #if temperature is lower than this threshold after start_script_time, reboot
check_interval=5 #check every 5 seconds
log="location where you want reboot log be saved"  #place where error log is saved

sleep $start_script_time

while [ 1 ]
#you may need to modify -c36-42 (meaning character 36 to 42 is cut from the output of command
#DISPLAY=:0 sudo aticonfig --odgt --adapter=all | grep C  which gives out the temperature of GPU 0)
        temp=`DISPLAY=:0 sudo aticonfig --odgt --adapter=all | grep C | cut -c36-42 | bc -l | awk -F '.' '{ print $1; exit; }'`

        if [ $temp -le $low_temp_threshold ] ; then
                echo "GPU temp: "${temp}"C" >> ${log}
                echo "$(date)" >> ${log}
                sleep $check_interval

Change permission of auto_reboot
chmod 755 auto_reboot
add a line to your /etc/rc.local (require sudo)

Please donate small amount to

The World's Betting Exchange

Bet with play money. Win real Bitcoin. 5BTC Prize Fund for World Cup 2018.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Offline Offline

Activity: 1330
Merit: 1000

View Profile
May 29, 2011, 05:18:51 AM

Not bad.  First of all it only works with one adapter.  You would be better off using 'sort' to select the one with the lowest temp.  Secondly I see no reason why you cannot just use 'cut -c37-38' with 'head -1' and get rid of 'bc' and 'awk'.  That would be simpler and a bit more portable.  Thirdly you probably want to test that you have a valid temperature before trying to compare it, and to quote your variables.  Fourth, it's better to use "$()" instead of `` for inline execution with bash.  And lastly, it is common to name variables in ALL_CAPS.

Civil Liberty Through Complex Mathematics
Offline Offline

Activity: 8
Merit: 0

View Profile
May 29, 2011, 10:57:50 AM

A fairly high percentage of the time a gpu locks up reboot fails anyway though Sad.

It's better to check your hash rate on the pool you're mining; that's what I do.
Pages: [1]
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!