1

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.

  • 1
    A bit of an issue there. cd Documents/eth-proxy . If i am not mistaken, cron will probably spawn the script with / as working directory. Give its full path. That way you can just avoid cd and just run python /home/user/Documents/script.py – Sergiy Kolodyazhnyy Aug 27 '16 at 1:10
  • Also, echo the messages with timestamp to a file. That way you can troubleshoot what doesn't work. Also, make echo statement conditional, so say that mining software is online only of it really is – Sergiy Kolodyazhnyy Aug 27 '16 at 1:12
  • Thanks for the pointer! I was able to make eth-proxy run by doing what you said; looks like geth and ethminer both are running now when cron runs initminer.sh.....but of course, now ethminer wont run! – cannabeatz Aug 27 '16 at 3:52
  • I can't see a possible error there. in ethminier line. By the way, just a tip: you don't need sudo, added to commands if your entire script runs as root – Sergiy Kolodyazhnyy Aug 27 '16 at 4:05
  • 1
    Thanks again! I realized that was unnecessary, but i put it in there to try to troubleshoot, since i'm at a loss for what to do! I got a bit more info this morning when i physically went to my machine (instead of SSH'ing in) and saw a Ubuntu "system problem detected" message that said "ethminer crashed with SIGSEGV in ADL2_Send()". research tells me this issue is due to a seg fault.......interestingly enough, it only happens when cron runs the job or if i run the script while SSH'ing into the machine. Works fine if i physically sit down at the machine and run the /etc/initminer.sh script... – cannabeatz Aug 27 '16 at 21:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.