Skip to content

Instantly share code, notes, and snippets.

@mcindea
Created March 2, 2021 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcindea/609f6b4a367f5d9f5181b8a6c470a198 to your computer and use it in GitHub Desktop.
Save mcindea/609f6b4a367f5d9f5181b8a6c470a198 to your computer and use it in GitHub Desktop.
Stops mining software nanominer if Plex Transcoder is running, and starts it again whenever Plex stops transcoding.
#!/bin/bash
# Limit the GPU power draw to 115W
nvidia-smi -pl 115
function check_if_active {
nvidia-smi --query-compute-apps=name --format=csv,noheader | grep -q "$1"
}
while : ;do
if check_if_active "Plex Transcoder"; then
check_if_active nanominer \
&& echo "Plex is transcoding, killing Nanominer" \
&& killall -9 nanominer
elif ! pidof nanominer &>/dev/null; then
echo "Seems Plex is not transcoding, starting Nanominer"
screen -S nano -d -m ./nanominer
fi
sleep 3
echo -n .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment