Author

Topic: Cgminer Sentinel scrypt for windows (Read 1283 times)

full member
Activity: 195
Merit: 100
February 08, 2014, 04:44:46 AM
#1
Hi everyone.

Been fighting the dreaded cgminer crashes for weeks.
Sometimes it runs for a few days, sometimes just a couple of hours but eventually one or more cgminer instance craps out.

I've given up. I'm tired of trying configs, drivers and voodoo spells, so I've written a simple powershell scrypt to look after my miners. It checks if all my cgminer threads are alive and running. If one or more threads are killed or not responding, it sends a restart signal and the computer reboots. Obviously the miners need to be launched from the Startup menu in windows.

Code:
Set-ExecutionPolicy RemoteSigned

$numThreads =  @(Get-Process -Name cgminer*).length
echo "numThreads = $numThreads"

while($true) {
$cpu1 = @(Get-Process -Name cgminer* | ForEach-Object {$_.cpu})

if ( $numThreads -ne $cpu1.length ) {
echo "Some thread died, restarting........."
taskkill /im "cgminer.exe" /f
shutdown /r
}

echo "c u in a minute..."
sleep 60
echo ""

$cpu2 = @(Get-Process -Name cgminer* | ForEach-Object {$_.cpu})

if ( $numThreads -ne $cpu2.length ) {
echo "Some thread died, restarting........"
taskkill /im "cgminer.exe" /f
shutdown /r
}

for ($i=0; $i -lt $cpu1.length; $i++) {
$outS = "Checking thread #" + $i + " activity. Before: " + $cpu1[$i] + " --- After: " + $cpu2[$i]

if ( $cpu1[$i] -eq $cpu2[$i]) {
echo $outS
echo $("Thread #" + $i + " not running, restarting.............")
taskkill /im "cgminer.exe" /f
shutdown /r

} else {
$outS + "... RUNNING OK" | echo
}
}
}

Just save that code in a file with a ps1 extension, something like sentinel.ps1 for example.

Then launch your miners from a batch, using start so that they run on their own threads, then in the same batch, run the sentinel scrypt in it's own thread too.
Use sleeps to ensure Windows has time to load completely and all cgminer instances are running before the sentinel starts running.

Code:
sleep 30
del *.bin
start "HD7970" cmd /c "cgminer-startup-7970.bat"
sleep 15
start "HD7950" cmd /c "cgminer-startup-7950.bat"
sleep 15
start "Sentinel" cmd /c "powershell .\Sentinel.ps1"
Jump to: