Bitcoin Forum
December 17, 2017, 04:48:23 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [TUT] Script - Get an e-mail when a block is found + updown checker (XPM)  (Read 802 times)
arby
Donator
Member
*
Offline Offline

Activity: 112


keybase.io/arblarg


View Profile
July 25, 2013, 08:25:26 AM
 #1

Ok well, as many others I am mining from different machines, and well, checking all of them for found blocks is very hard, also I am not using the same wallet for all of them so basically I prefer the machines to e-mail me when they find a block.

Also the script checks if primecoind is still running, and if it's not it tries to start it again.

1. Install a mail server (if you don't have one) so that you can receive e-mails

On Debian/Ubuntu you should install exim4 in order to get your e-mail working.
Code:
apt-get update
apt-get upgrade
apt-get install exim4-daemon-light mailutils
dpkg-reconfigure exim4-config

On CentOS/Slackware/Arch/Gentoo I am sure you will find many tutorials of doing this.

2. Save this script in a file and make it executable (chmod +x filename)

Code:
#!/bin/bash

primecoind=`which primecoind`

#we check if primecoind is running and if not we start it again
if ! pgrep -f $primecoind >/dev/null 2>&1; then
$primecoind --daemon
sleep 10
fi

#we check if a block was found or not
generated=`cat $HOME/.primecoin/debug.log | grep generated | grep -v prime | sed 's/generated //g'`

if [ -z "$generated" ] ; then
exit
fi

#we found a block
ip=`hostname -I`
$primecoind listtransactions | /usr/bin/mail -s "I found one! $generated XPM $ip" -r primecoind@$ip  your@email.com

#clean up and server restart
$primecoind stop
sleep 10
rm -rf $HOME/.primecoin/debug.log
$primecoind --daemon

3. Add this to your cron daemon

Code:
crontab -e

And add the following:

For 15 minutes checks:

Code:
0,15,30,45 * * * * /path/to/yourscript

For hourly checks:

Code:
0 */2 * * *  /path/to/yourscript

Save and close.

To check that it was added:

Code:
crontab -l

Regards

P.S. This script can be easily modified to work with any daemon by fiddling with 'which primecoind' maybe replacing it with 'which bitcoind', not just the primecoin one, because I think they all work the same way.

Jabber/XMPP: arby@darkness.su
1513486103
Hero Member
*
Offline Offline

Posts: 1513486103

View Profile Personal Message (Offline)

Ignore
1513486103
Reply with quote  #2

1513486103
Report to moderator
1513486103
Hero Member
*
Offline Offline

Posts: 1513486103

View Profile Personal Message (Offline)

Ignore
1513486103
Reply with quote  #2

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

Posts: 1513486103

View Profile Personal Message (Offline)

Ignore
1513486103
Reply with quote  #2

1513486103
Report to moderator
k0vic
Member
**
Offline Offline

Activity: 113



View Profile
July 28, 2013, 11:49:36 PM
 #2

Who would one do this in windows? It would save me so much time Smiley

LTC- LKNm2UVuBgMLJNPU7pV5cgQnGx6PWGk7Ju
BTC- 1NHcECfk8oxJe83m9bPME2cdUCY72vuA2Y
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!