here is my daggen.sh for HiveOS
#!/bin/bash
a=$(cat /run/hive/last_stat.json | jq '.params .miner_stats .uptime')
echo "$a"
if [[ "$a" -gt "120" ]];then
echo "greater than 120 seconds, restarting"
sudo reboot
fi
You need to install JQ first: sudo apt-get install jq (json parser)
Basically, if the miner has run for more than 2 minutes and sees a new dag, reboot the machine.
There is obviously a chance for a new dag to come before 2 minutes and you wont get a reboot, but this will solve the 99.9% situation as the dag is only generated once every 6000 minutes (100 hours).