Bitcoin Forum
April 27, 2024, 03:04:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: [TUT] Script - Get an e-mail when a block is found + updown checker (XPM)  (Read 862 times)
arby (OP)
Donator
Member
*
Offline Offline

Activity: 112
Merit: 10


keybase.io/arblarg


View Profile
July 25, 2013, 08:25:26 AM
Last edit: November 17, 2015, 11:05:15 AM by arby
 #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
1714187053
Hero Member
*
Offline Offline

Posts: 1714187053

View Profile Personal Message (Offline)

Ignore
1714187053
Reply with quote  #2

1714187053
Report to moderator
1714187053
Hero Member
*
Offline Offline

Posts: 1714187053

View Profile Personal Message (Offline)

Ignore
1714187053
Reply with quote  #2

1714187053
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714187053
Hero Member
*
Offline Offline

Posts: 1714187053

View Profile Personal Message (Offline)

Ignore
1714187053
Reply with quote  #2

1714187053
Report to moderator
1714187053
Hero Member
*
Offline Offline

Posts: 1714187053

View Profile Personal Message (Offline)

Ignore
1714187053
Reply with quote  #2

1714187053
Report to moderator
1714187053
Hero Member
*
Offline Offline

Posts: 1714187053

View Profile Personal Message (Offline)

Ignore
1714187053
Reply with quote  #2

1714187053
Report to moderator
k0vic
Member
**
Offline Offline

Activity: 113
Merit: 10



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:  

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