Bitcoin Forum
May 04, 2024, 11:48:50 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Automated cgminer monitor and restart script  (Read 1774 times)
jbass350z (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
February 16, 2014, 06:37:51 PM
 #1

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
1714823330
Hero Member
*
Offline Offline

Posts: 1714823330

View Profile Personal Message (Offline)

Ignore
1714823330
Reply with quote  #2

1714823330
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, but full nodes are more resource-heavy, and they must do a lengthy initial syncing process. As a result, lightweight clients with somewhat less security are commonly used.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
twistedtrick
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
April 02, 2014, 12:00:49 AM
 #2

Very useful, thank you for the script.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!