Author

Topic: batchfile to restart cgminer in Windows, if a card dies (Read 4937 times)

sr. member
Activity: 378
Merit: 250
Absolutely. It records the timedate stamp of when this happens, and worked for me twice so far.
I did decide to search for the word "SICK" and not DEAD to catch problems quicker. But you can
search for loss of connection also. The other good thing is that once your batchfiles are all set-up
correctly, you can leave CG_Kill running and switch to another cg batchfile because it reads the name
of what file to restart on every cycle. I'm very pleased with it.
hero member
Activity: 714
Merit: 500
what if CGMiner dies, will it restart it?
sr. member
Activity: 378
Merit: 250
Thanks, I may check it out. Once this bat code is tweaked & confirmed - I think it's simpler to use
& definitely "open source"  lol
sr. member
Activity: 378
Merit: 250
I have not actually HAD a card die since I got this going, but I'm 99% certain it will work.
I did alot of research on various aspects of batchfile functions to piece this together.
I know the cgwatcher program can do this, but this is simpler.

There are five steps:

1) Make a file in your cgminer directory called INPUT.txt with FILE= in it.

2) Put this line in all your various cg batchfiles: ECHO FILE= > INPUT.txt

3) Put the following into any batchfile name you want: (I use CG_Kill.bat)

REM Requires cgminer to be run with 2>Log.txt parameter AFTER
REM starting this batchfile.
REM Requires statement of FILE=
REM in a file called INPUT.txt
REM Also, in all your different cgminer batchfiles, put a
REM line to ECHO it's name to the input file like:
REM ECHO FILE=cg.bat > INPUT.txt

DEL Log.txt
SET /A COUNT=0

:LOOP
SET /A COUNT+=1
REM get name of current cgminer batchfile
for /f "delims=" %%x in (INPUT.txt) do (set "%%x")

REM check for dead card and restart cgminer, if so...
FINDSTR /m "DEAD" Log.txt
if %errorlevel%==0 (
Taskkill /IM cgminer.exe /F
TIMEOUT 10
ECHO %DATE% >> RESTARTS.txt
ECHO %TIME% >> RESTARTS.txt
DEL Log.txt
REM insert name of cgminer start batchfile after this line
START CALL %FILE%
)

REM Deletes Logfile every hour so that searching it is quick enough.
IF "%COUNT%" == "30" (
Taskkill /IM cgminer.exe /F
TIMEOUT 10
DEL Log.txt
SET /A COUNT=0
REM insert name of cgminer start batchfile after this line
START CALL %FILE%
)

REM wait two minutes to recheck for dead card
TIMEOUT 120

GOTO LOOP

4) Requires cgminer to be run with 2>Log.txt parameter AFTER
starting this batchfile.

5) Add an EXIT command after the cgminer command to your cg batchfiles. (prevent multiple open windows)
So, if your cg batchfile was coinpool.bat you would have this in it:

ECHO FILE=coinpool.bat > INPUT.txt
cgminer blah blah 2>Log.txt
EXIT

Note: it will restart cgminer once an hour as part of the process of not letting the logfile get too big.
Jump to: