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#!/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.cfgexport RIC_USER=yourusername.yourworker
export RIC_PASS=yourpassword
status#!/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#!/bin/bash
{
killall -q start-miner xptminer
} >/dev/null 2>&1
restart-miner#!/bin/bash
./stop-miner
./start-miner
Donations no matter how small are much appreciated.
BTC 1PkWYuA6cgXwsFh1ggT52ZcMwSxjoBt6sY
RIC: RJ5bZXAYx3mChkGGo6X2D56KLZvWunBojK