Bitcoin Forum
December 04, 2016, 12:34:44 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: linux auto reboot bash script in case of gpu lock  (Read 2991 times)
hipaulshi
Jr. Member
*
Offline Offline

Activity: 32


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

if you are like me and have set up a dedicated ubuntu as a mining machine (according to this post http://forum.bitcoin.org/index.php?topic=9239.0)and 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.

Prerequisite:
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
Code:
#!/bin/bash
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 ]
do
#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}
                reboot
        fi
                sleep $check_interval
done


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


Donation
Please donate small amount to
15ecuau8Y2KAe6ghBHZwBEKU2W7K6aLKw2

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

Posts: 1480854884

View Profile Personal Message (Offline)

Ignore
1480854884
Reply with quote  #2

1480854884
Report to moderator
1480854884
Hero Member
*
Offline Offline

Posts: 1480854884

View Profile Personal Message (Offline)

Ignore
1480854884
Reply with quote  #2

1480854884
Report to moderator
benjamindees
Legendary
*
Offline Offline

Activity: 1288


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

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
lastobelus
Newbie
*
Offline Offline

Activity: 8


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

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]
  Print  
 
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!