Bitcoin Forum
September 25, 2018, 12:21:07 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: batchfile to restart cgminer in Windows, if a card dies  (Read 4807 times)
FiatKiller
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
May 28, 2013, 06:32:59 PM
 #1

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=<name of cgminer batchfile> in it.

2) Put this line in all your various cg batchfiles: ECHO FILE=<name of cgminer batchfile> > 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=<name of cgminer batchfile>
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 <parameters> 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.

LTC: LdxgJQLUdr8hZ79BV5AYbxkBUdaXctXAPi
MoonCoin Gambling: https://coin-horse.com/MON/
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1537878067
Hero Member
*
Offline Offline

Posts: 1537878067

View Profile Personal Message (Offline)

Ignore
1537878067
Reply with quote  #2

1537878067
Report to moderator
af_newbie
Legendary
*
Offline Offline

Activity: 1442
Merit: 1073



View Profile
May 29, 2013, 03:01:24 AM
 #2

check my signature if you are looking for a watchdog
FiatKiller
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
May 29, 2013, 10:56:46 AM
 #3

Thanks, I may check it out. Once this bat code is tweaked & confirmed - I think it's simpler to use
& definitely "open source"  lol

LTC: LdxgJQLUdr8hZ79BV5AYbxkBUdaXctXAPi
MoonCoin Gambling: https://coin-horse.com/MON/
qiuness
Hero Member
*****
Offline Offline

Activity: 714
Merit: 500


OPEN GAMING PLATFORM


View Profile WWW
June 09, 2013, 08:42:12 PM
 #4

what if CGMiner dies, will it restart it?

FiatKiller
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
June 10, 2013, 12:26:24 PM
 #5

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.

LTC: LdxgJQLUdr8hZ79BV5AYbxkBUdaXctXAPi
MoonCoin Gambling: https://coin-horse.com/MON/
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!