Title: How do I write this grep argument? Post by: mackminer on October 01, 2011, 02:23:44 PM #!/bin/sh
HIGH=70 SHUTDOWN_TEMP=85 export HIGH export SHUTDOWN_TEMP while true do # read temp TEMP=`sensors|grep 'CPU Temp'|cut -d+ -f2|cut -d. -f1` if [ "$TEMP" -gt "$HIGH" ]; then echo "High temp: $TEMP > $HIGH" | wall sleep 2 else if [ "$TEMP" -gt "$SHUTDOWN_TEMP" ]; then echo "To hot, shutting down in 30 sek.!" | wall sleep 30 sudo shutdown now else echo temp OK: $TEMP sleep 5 fi fi done Here is the output of my script for the below screenshot... #!/bin/bash watch -n 1 aticonfig --adapter=0,1,2,3,4,5 --od-gettemperature On the bold and underlined row in the temp script below I need to figure out how to get the temps out. Any help greatly appreciated - thanks! http://img705.imageshack.us/img705/8200/watchoutput.jpg (http://imageshack.us/photo/my-images/705/watchoutput.jpg/) Uploaded with ImageShack.us (http://imageshack.us) Title: Re: How do I write this grep argument? Post by: mackminer on October 01, 2011, 08:27:12 PM Thanks for your help so far. I am still having an issue though.
When running the below I get user@system:~$ ./overheat [: 31: Illegal number: [: 31: Illegal number: temp OK: This is the script with added changes: #!/bin/sh HIGH=70 SHUTDOWN_TEMP=85.00 export HIGH export SHUTDOWN_TEMP while true do # read temp TEMP=`aticonfig --adapter=0 --od-gettemperature |grep Sensor |cut -d '-' -f2|cut -d 'C' -f3` if [ "$TEMP" -gt "$HIGH" ]; then echo "High temp: $TEMP > $HIGH" | wall sleep 2 else if [ "$TEMP" -gt "$SHUTDOWN_TEMP" ]; then echo "To hot, shutting down in 30 sek.!" | wall sleep 30 sudo shutdown now else echo temp OK: $TEMP sleep 5 fi fi done Title: Re: How do I write this grep argument? Post by: mackminer on October 01, 2011, 10:01:52 PM Whoops, with f1 at the end I get the below....
[: 31: Illegal number: 74.50 [: 31: Illegal number: 74.50 temp OK: 74.50 If I change the first line to #!/bin/bash I get this... ./overheat: line 15: [: 74.50 : integer expression expected ./overheat: line 20: [: 74.50 : integer expression expected temp OK: 74.50 I'm not sure what the difference is between sh and bash though. Title: Re: How do I write this grep argument? Post by: nomnomnom on October 01, 2011, 11:26:36 PM Hello,
I am not a great scripter, but from your screenshot it looks like you want this for multiple gpus? If so I think you need to add some for loop. I would do it like that: Code: #!/bin/sh and yeah I think it should be shutdown -h now like the poster above me says :D Title: Re: How do I write this grep argument? Post by: mackminer on October 02, 2011, 06:48:00 PM Hello, I am not a great scripter, but from your screenshot it looks like you want this for multiple gpus? If so I think you need to add some for loop. I would do it like that: Code: #!/bin/sh and yeah I think it should be shutdown -h now like the poster above me says :D Excellent! That works perfectly. Is it possible to get the script to email me with an update of temps every hour and an email if the temperature exceeds high? Also how do I set this script to run automatically in the background and how to let me know if it's failed? Thanks a mill. Title: Re: How do I write this grep argument? Post by: nomnomnom on October 03, 2011, 02:53:39 AM I was thinking, oh this is no problem just add one line so it sends an email.
BUT this was a little bit more complicated. Because if the temp is at the $HIGH warning point, it sleeps 2 seconds and the goes on again. If I just put a mail command there it sends a mail every few seconds, probably not so good LOL. So I made a timestamp and check if it sent mail in the last 5 minutes (found that here: http://stackoverflow.com/questions/205666/what-is-the-best-way-to-perform-timestamp-comparison-in-bash) And how to make it send the ok temps every hour? I now made it log the temps to a file, so you can make a cronjob that mails it to you every hour (/tmp/temp.log). Also I think this script had a bug, the shutdown stuff never executed because even if you reach $SHUTDOWN_TEMP, the temp is higher then the $HIGH temp and so it never went into the else loop. Moved that shutdown stuff at the beginning now, so it gets checked first. But I probably created more bugs now haha 8) You can start the script with a $ at the end, so it keeps running in the background. Maybe you have a startup script for your miners, then you can just add it at the end. Code: #!/bin/sh Title: Re: How do I write this grep argument? Post by: nomnomnom on October 03, 2011, 10:33:08 PM You can start the script with a $ at the end, so it keeps running in the background. That would be & to background. Whoops, thanks for noticing that, of course you are right ;) Title: Re: How do I write this grep argument? Post by: mackminer on October 04, 2011, 06:03:17 PM I actually took out the high temp part and just left in the shutdown part. My room is air conditioned so if the temp is ever up to that then there's something seriously wrong and it should be shut down. My setup would not warrant clocking gpu's down for cooling.
Also I used a little program called sendEmail, it allows you to send email from the command line with minimal setup (very basic). I put all my details into a second script and call it from the first. It will tell me that the temp has exceeded and it's shutting down - just so I'm aware! Title: Re: How do I write this grep argument? Post by: Shevek on October 06, 2011, 08:56:20 AM Perhaps you should go to cgminer.
It has control system over fan and engine clock (you can switch them or not) in order to set temperature under fixed target (by default 75C). You can define highest temp to stop mining (def. 85C) and highest temp to keep away (def. 95C). Give it a try. It's sticked in top ten. |