Bitcoin Forum
August 19, 2018, 10:02:02 PM *
News: Latest stable version of Bitcoin Core: 0.16.2  [Torrent].
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: Cgminer Sentinel scrypt for windows  (Read 1174 times)
Full Member
Offline Offline

Activity: 202
Merit: 100

View Profile
February 08, 2014, 09:44:46 AM

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.

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.

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]
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!