Bitcoin Forum

Alternate cryptocurrencies => Mining (Altcoins) => Topic started by: jbass350z on February 16, 2014, 06:37:51 PM



Title: Automated cgminer monitor and restart script
Post by: jbass350z on February 16, 2014, 06:37:51 PM
My BAMT would go down randomly every once in awhile and it sucked leaving home for a few hours only to return to dead miners. Crontab is the answer. I ran across another guys post awhile back and tweaked it for BAMT use.
Below assumes you are logged in as root:

Create file:  /home/user/cron/checker.sh

1. cd /home/user
2. mkdir cron
3. cd cron
4. nano checker.sh
5. Inside file put the following:
Code:
#!/usr/bin/env bash
ps -A | grep cgminer > cgminer.status
if [[ -s cgminer.status ]] ; then
echo "running eval date +%T_%d-%m-%Y " >> cgminer.log
else
echo "NOT running eval date +%T_%d-%m-%Y " >> cgminer.log
/etc/init.d/mine restart
fi;
6. chmod 755 checker.sh

Save the file:
1. ctrl+x
2. y
3. enter

Edit crontab:
1. nano /etc/crontab
2. Add this at the bottom:
3. */15 * * * * root cd /home/user/cron && ./checker.sh >/dev/null 2>&1
4. ctrl+x
5. y
6. enter

Restart crontab:
1. service crontab restart

So what does this do? It checks cgminer ever 15 minutes and logs whether or not it is working. If it is not running it restarts cgminer.

If you want to to reboot the machine instead restart cgminer change this line:
Code:
/etc/init.d/mine restart

to

Code:
coldreboot
---------------------------------------------
BTC: 168YcXH4Xxu4i7yjokxvNvx4X6CLKuuUaZ
LTC: Lb2mTzKX2ZR8M2WDM1N2yppcoyPHN9cUdN
DOGE: DMHdTbVj5X7A74jGcnMBiivyXkhHXYFTDg


Title: Re: Automated cgminer monitor and restart script
Post by: twistedtrick on April 02, 2014, 12:00:49 AM
Very useful, thank you for the script.