Bitcoin Forum
May 24, 2024, 06:48:10 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Riecoin xptminer start script (ypool and others)  (Read 1188 times)
baaaah (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
March 04, 2014, 11:23:02 PM
 #1

I noticed that ypool.net is quite unstable at times and that sometimes xptminer would be stuck waiting for the pool to be reachable again.
The script checks every minute if xptminer is mining (CPU utilization of xptminer > 50%) and, if not, restarts it.

The script can also be used for other pools/currencies.

Put all files in the same directory and launch it from there with ./start-miner. It runs in background and logs output to miner.log. Use ./status to get some info.

start-miner
Code:
#!/bin/bash
LOG=miner.log
CRASHLOG=crash.log
HOST=ypool.net:8085
. miner.cfg
cores=$(cat /proc/cpuinfo | grep processor | wc -l)

echo Starting miner
killall --older-than 60s -q xptminer
echo -n > $LOG 2>/dev/null
background_loop() {
    while :; do
        xptMiner/xptminer -o ${HOST} -u ${RIC_USER} -p ${RIC_PASS} -t ${cores} > $LOG 2>&1
        sleep 5
        date >> $CRASHLOG
    done
}

background_check() {
    while :; do
        sleep 60
        PID=$(pidof xptminer)
        CPU=$(ps -o pcpu= ${PID} | cut -d' ' -f2 | cut -d. -f1)
        if [[ "$CPU" -le 50 ]]; then
            echo $CPU
            echo "$(date) low-cpu restart" >> $CRASHLOG
            ./restart-miner
            exit
        fi
    done
}

background_loop &
background_check &

miner.cfg
Code:
export RIC_USER=yourusername.yourworker
export RIC_PASS=yourpassword

status
Code:
#!/bin/bash
LOG=miner.log
if [ -f "$LOG" ]; then
    tail -n 5 $LOG
    echo
    echo '=========================================================='
    echo
fi
echo "Memory Info:"
PID=$(pidof xptminer)
if [ -n "$PID" ]; then
    ps fup $PID
fi
echo
free -h

stop-miner
Code:
#!/bin/bash
{
    killall -q start-miner xptminer
} >/dev/null 2>&1

restart-miner
Code:
#!/bin/bash
./stop-miner
./start-miner

Donations no matter how small are much appreciated.
BTC 1PkWYuA6cgXwsFh1ggT52ZcMwSxjoBt6sY
RIC: RJ5bZXAYx3mChkGGo6X2D56KLZvWunBojK
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!