Bitcoin Forum
May 30, 2024, 08:36:22 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Cgminer Sentinel scrypt for windows  (Read 1267 times)
dazz (OP)
Full Member
***
Offline Offline

Activity: 195
Merit: 100



View Profile
February 08, 2014, 09: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"
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!