This one is quite simple, it uses cron which runs periodic tasks.
You can quite easily modify this for any software, example uses cgminer.
to disable logging just remove "echo ..." lines from the watchdog.sh
this doesnt work if you run multiple instances of the same miner, also it doesnt restart dead gpus etc...
You dont need separate script in init or anything, if you use time interval short enough to start miner after boot.
This merely checks if miner process is running, thats all.
create "/home/username/start_cgminer" with following content:
screen -S cgminer -d -m cgminer --auto-fan --auto-gpu
then make it executable: "chmod 755 start_cgminer"
to keep it running i made script: "/home/username/cron/watchdog.sh"
#!/usr/bin/env bash
ps -A | grep cgminer > cgminer.status
if [[ -s cgminer.status ]] ; then
echo "running `eval date +%T_%d-%m-%Y` " >> cgminer.log
else
echo "NOT running `eval date +%T_%d-%m-%Y` " >> cgminer.log
/home/username/start_cgminer
fi;
then make it executable: "chmod 755 watchdog.sh"
start editor for user crontab: "crontab -e"
add line to the end, this runs watchdog.sh every 2 minutes.
*/2 * * * * /home/username/cron/watchdog.sh >/dev/null 2>&1
if you want different interval for example every 6 hours:
* */6 * * * /home/username/cron/watchdog.sh >/dev/null 2>&1
Donations appreciated as usual