Post
Topic
Board Mining support
Re: USB ASIC ERUPTER - Setup & Config. BCG Miner, cgminer & Hubs "Oh Pi"!
by
kano
on 21/09/2013, 08:32:16 UTC
...
Interesting. Makes sense. Could you share your cron job ? It's not ideal but should get me hashing again until Raspbian gets a fix.
...
I have a program I wrote > 10 years ago (sem) that simply does nothing in the case (in this example) that the script tries to run twice at the same time - so this script would require a bit of work to get it going ... but anyway here's the concept:
Code:
#!/bin/bash
#
#set -x
#
sem="/root/chkpisem"
#
if [ "$1" != "boo" ] ; then
 touch "$sem"
 /root/sem -q "$sem" "$0" "boo" >> /root/chkpi.log 2>&1
 exit 0
fi
#
last="/root/lastchkpi"
#
ip1="192.168.?.?"
ip2="192.168.?.?"
ip3="192.168.?.?"
#
chk()
{
 ping -n -w 5 -c 1 "$1" 2>&1
 r="$?"

 if [ "$r" == "0" ] ; then
echo -e "`date "+%s"`\nLast Valid Ping to $1: `date`" > "$last"
# stop checking as soon as we find one
exit 0
 fi
}
#
# In case of network delays during system startup
sleep 60
#
chk "$ip1" > /dev/null
chk "$ip2" > /dev/null
chk "$ip3" > /dev/null
#
now="`date "+%s"`"
lst="`head -1 "$last"`"
#
dif="`echo "$now $lst - p" | dc`"
#
# 5 minutes
if [ "$dif" -gt "299" ] ; then
 date
 echo "No ping for 5 minutes (dif=$dif) ..."
 chk "$ip1"
 chk "$ip2"
 chk "$ip3"
 echo "Shutting down ..."
 /root/cgdown
fi

And then the cgdown script - though I could update this to use Multicast - but I haven't Smiley
It just sends a 'quit' to all ports 4020 to 4049
Code:
#!/bin/bash
#
echo "`date`: CGDOWN"
#
i="4020"
while [ "$i" -lt "4050" ] ; do
 echo "127.0.0.1 $i"
 echo -n quit | nc -4 -w 1 127.0.0.1 $i
 i=$[$i+1]
done
#
echo "`date` sleep 10"
sleep 10
#
date
#
echo "shutdown -h now"
shutdown -h now

The whole process is quite slow - but the point is that rather than having to switch it off if you don't have a keyboard+screen, it will do it itself.
You could of course change it to "shutdown -r now" - though if the network didn't came back up alive it would keep doing it over and over.

There are probably better ways to do this - but this one is pretty simple Smiley