Created
May 17, 2021 23:46
-
-
Save eddiez9/7b544a8c7a2cc7de86a62152276db9fd to your computer and use it in GitHub Desktop.
Idle mining with GPU https://www.reddit.com/r/linux_gaming/comments/mqilcq/mine_with_your_idle_gpu/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script checks for the presence of a process using high GPU memory other than its own etherum miner, and terminates the miner. If it does not find such a process, it starts the miner. | |
MAX_MEMORY=500 | |
MINER_NAME=t-rex | |
MINER_PATH="/home/trex/t-rex -a ethash -o stratum+tcp://asia1.ethermine.org:4444 -u WALLET_ADDRESS -w hashcat1" | |
# Get data on GPU processes | |
gpuprocs=$(nvidia-smi | head -n -1 | sed -n -e '19,999999 p' | awk 'BEGIN{ OFS = ";"; FS=" *"}{split($0,a);print a[5],a[6],(a[8]+0)}') | |
for proc in $gpuprocs | |
do | |
memory=$(echo $proc | awk -F";" '{print $3}') | |
pid=$(echo $proc | awk -F";" '{print $1}') | |
if [ $memory -gt $MAX_MEMORY ] && [ $(ps -p $pid -o comm=) != $MINER_NAME ]; then | |
echo "Found priority process, killing miner..." | |
tpids=$(pidof $MINER_NAME) | |
for tpid in $tpids | |
do | |
echo "Killing $tpid." | |
kill $tpid | |
done | |
echo "Done here, exiting" | |
exit 0 | |
fi | |
done | |
pidof $MINER_NAME >/dev/null && echo "Miner is already running" || /usr/sbin/runuser -l trex -c "screen -dmS trex $MINER_PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment