How to Restart a BAT file on Windows at an Interval

I recently wrote a .bat script on Windows to mine Ethereum when I’m not using my gaming PC to frag noobs. I have a friend who also tries to mine cryptocurrencies but their machines have AMD processors; every once in a while, the processor and the mining executable start fighting and all mining comes to […]

The post How to Restart a BAT file on Windows at an Interval appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

I recently wrote a .bat script on Windows to mine Ethereum when I’m not using my gaming PC to frag noobs. I have a friend who also tries to mine cryptocurrencies but their machines have AMD processors; every once in a while, the processor and the mining executable start fighting and all mining comes to a halt.

Having the mining .exe stop work but not kill the process is a really frustrating problem. I thought it was a Windows sleep/hibernation issue but the solution I wrote about in that post didn’t fix the problem. I went with the next best solution: killing and restarting the process after a given amount of time:

:loop
start PhoenixMiner.exe -pool us1.ethermine.org:4444 -pool2 us1.ethermine.org:4444 -wal WALLET_ADDRESS -proto 3
echo "-------------------------------MINER STARTED"
timeout /t 3600 >null
echo "-------------------------------MINER TERMINATED, RESTARTING"
taskkill /f /im "PhoenixMiner.exe" > null
goto loop

This script kills the process and restarts it after an hour, regardless of if mining is running smoothly or has quit. This obviously isn’t a perfect solution; a better answer would be to create a script to listen for an error and restart the process immediately. I will contend it’s a workable solution so that mining isn’t down for an entire night!

The post How to Restart a BAT file on Windows at an Interval appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2021-06-03T22:33:45+00:00) How to Restart a BAT file on Windows at an Interval. Retrieved from https://www.scien.cx/2021/06/03/how-to-restart/

MLA
" » How to Restart a BAT file on Windows at an Interval." David Walsh | Sciencx - Thursday June 3, 2021, https://www.scien.cx/2021/06/03/how-to-restart/
HARVARD
David Walsh | Sciencx Thursday June 3, 2021 » How to Restart a BAT file on Windows at an Interval., viewed ,<https://www.scien.cx/2021/06/03/how-to-restart/>
VANCOUVER
David Walsh | Sciencx - » How to Restart a BAT file on Windows at an Interval. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/03/how-to-restart/
CHICAGO
" » How to Restart a BAT file on Windows at an Interval." David Walsh | Sciencx - Accessed . https://www.scien.cx/2021/06/03/how-to-restart/
IEEE
" » How to Restart a BAT file on Windows at an Interval." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2021/06/03/how-to-restart/. [Accessed: ]
rf:citation
» How to Restart a BAT file on Windows at an Interval | David Walsh | Sciencx | https://www.scien.cx/2021/06/03/how-to-restart/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.