I have a crontab setup under root that launches a script i've made that starts my mining rig. Here's what the crontab looks like
@reboot /etc/initminer.sh */5 * * * * /etc/zombiescan.sh
I know that zombiescan.sh works fine if i launch it from a normal shell; it just checks if ethminer is running. If not, it reboots the rig (crude, i know but it seems to work). Zombiescan.sh looks like this:
#!/bin/bash if pgrep "ethminer" > /dev/null then echo "Ethminer Running, continuing....." else echo "Ethminer is STOPPED. Rebooting......" sleep 3 sudo reboot fi
I also know that initminer.sh works just fine if ran from a regular shell, here's what that looks like:
#!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin/bin:/home/miner/etc/initminer.sh #Program starts 3 tmux sessions that each run geth, eth-proxy, and ethminer respectively. sudo tmux new-session -d -s geth 'sudo geth' sudo tmux detach -s geth sleep 1 echo "Geth RPC Server Online! Sleeping 5 seconds...." sleep 5 sudo tmux new-session -d -s eth-proxy 'cd Documents/eth-proxy && sudo python eth-proxy.py' sudo tmux detach -s eth-proxy sleep 1 echo "Eth-Proxy Online! Sleeping 5 seconds..." sleep 5 sudo tmux new-session -d -s ethminer 'sudo ethminer --farm-recheck 200 -G -F http://127.0.0.1:8080/Andromeda --cl-local-work 256 --cl-global-work 8192' sudo tmux detach -s ethminer sleep 1 echo "Ethminer (C++) Mining software Online! Sleeping 5 seconds..." sleep 1 echo "_________________________________________________________________" sleep 1 echo "_________________________________________________________________" sleep 1 echo "_________________________________________________________________" sleep 1 echo "_________________________________________________________________" sleep 1 echo "Miner, RPC, XINIT, GPU Temperature Monitoring and Stratum Proxy started!" sleep 1 echo "Be sure to check tmux status of each process!"
Now here's my issue: For some reason, whenever CRON starts initminer.sh, only the first tmux command is being ran (geth). It starts tmux and runs geth successfully before detaching, but after that nothing else is ran. What am i doing wrong?
To troubleshoot, I installed postfix as an MTA and have been checking the "mail" it sends me to monitor whats going on when the script is launched. I'm not getting any errors (because none are happening, apparently).
** Please excuse my formatting....first time poster and i haven't quite figured out how to use the code snippet insert!
EDIT 1: So after a bunch of troubleshooting, it looks like I have either an issue with the environment variables that cron is using when running the script, or some sort of permissions issue. This is the first time I've ever actually used cron, so it seems I have quite a bit of reading to do.