Can I offer the following script? I use with momchils poclbm miner. The script is written in perl and you use from your name space as follows:
./mine.pl start
./mine.pl stop
You need to set your user and password, and also the directory containing the miner, (whichever version) and logs. Other than that usage should be simple.
It will seek out as many GPU's as you have, and fire them all up. It can also be used to switch on an off at idle although I havnt used this functionality recently. Chang options for the miner as you need.
Script is intended to be run as user not as root.
#!/usr/bin/perl
# usage:
# mine.pl start
# start mining now
# mine.pl stop
# stop mining now
# mine.pl idle start
# start mining when screen saver activates, stop it when it deactivates.
# this means if you started by hand it will stop when screen saver deactivates.
# mine.pl idle stop
# do not do anything on screen saver activate/ deactivate.
#
# Note that for this functionality you must be using xscreensaver, it will not work
# otherwise.
#
# mine.pl logsort
# sort log files into 1 per day files. Must be done only while miner is stopped.
#
$dir="/home/mark/poclbm20110311";
# $dir='/home/mark/poclbm20110311/poclbm-mod.03.24.2011';
#$dir='/home/mark/poc/m0mchil-poclbm-b981138';
$logdir="/home/mark/poclbm20110311";
use POSIX qw(strftime);
if ($ARGV[0] eq 'logsort')
{
logsort();
exit;
}
# idle stop means uncouple. Next time computer becomes idle
# nothing will happen.
if ($ARGV[0] eq 'idle' and $ARGV[1] eq 'stop')
{
chdir($dir);
my $f="$0.idle.pid";
if ( -e $f)
{
$pid=`cat $f`;
print "kill $pid\n";
system("kill $pid");
sleep 1;
-e $f and unlink $f;
}
exit 0;
}
# idle start means next time computer becomes idle
# start mining.
if ($ARGV[0] eq 'idle' and $ARGV[1] eq 'start')
{
# BLANK Wed Mar 16 17:06:30 2011
# RUN 176
# UNBLANK Wed Mar 16 17:06:43 2011
chdir($dir);
$chi=fork;
if ($chi==0)
{ open (IN, "xscreensaver-command -watch |");
while (
) {
if (m/^(BLANK|LOCK)/) {
if (!$blanked) {
system("$0 start");
$blanked = 1;
}
} elsif (m/^UNBLANK/) {
system("$0 stop");
$blanked = 0;
}
}
}
else
{
# print "child is $chi\n";
open(P,">$0.idle.pid") or die "Y";
$chi=$chi+1;
print P "$chi";
close P;
}
exit 0;
}
if ( $ARGV[0] eq 'stop' or $ARGV[0] eq 'start' )
{
system("killall poclbm.py > /dev/null 2&>1 ");
}
$sdk="/home/mark/src/bitcoin/ati/ati-stream-sdk-v2.3-lnx32/lib/x86";
$sdk="/home/mark/src/bitcoin/ati/ati-stream-sdk-v2.3-lnx32/lib/gpu";
# $sdk="/home/mark/src/bitcoin/ati/ati-stream-sdk-v2.1-lnx32/lib/x86";
$poclbm="cd $dir ; export GPU_USE_SYNC_OBJECTS=1 ; export LD_LIBRARY_PATH=$sdk ; export DISPLAY=:0 ; ./poclbm.py";
if ($ARGV[0] eq 'start')
{
open(X, "$poclbm |") or die "Cannot open miner to determine GPUs";
# example output expected:
# # [1] Cypress
# [2] Intel(R) Core(TM) i7 CPU 950 @ 3.07GHz
while ()
{
chomp;
m/Cypress/ and m/^.([0-9]+)/ and push(@d,$1);
}
close X;
for my $d (@d)
{
start($d);
}
exit 0;
}
sub start
{
my ($d)=@_;
my $chi;
open(F,">>$logdir/poclbm$d.log") or die("X");
$chi=fork();
if (!$chi)
{
$v=`cd $dir ; export GPU_USE_SYNC_OBJECTS=1 ; export LD_LIBRARY_PATH=$sdk ; export DISPLAY=:0 ; ./poclbm.py --version 2>&1 `;
$v=~s/\n//;
print F strftime("%d/%m/%Y %H:%M:%S, ",localtime());
print F "*** $v started $d \n";
close F;
system("cd $dir ; export GPU_USE_SYNC_OBJECTS=1 ; export LD_LIBRARY_PATH=$sdk ; export DISPLAY=:0 ; ./poclbm.py -f 20 --verbose -w 128 -r 60 -v -d$d --user ... --pass ... >> $logdir/poclbm$d.log 2>&1");
open(F,">>$logdir/poclbm$d.log") or die("X");
print F strftime("%d/%m/%Y %H:%M:%S, ",localtime());
print F "*** stopped $d \n";
close F;
exit;
}
}
sub logsort
{
my $d=0;
my %devices;
my $l="$logdir/poclbm$d.log";
$devices{$l}=$d;
# 1) List all the log files in existence.
while ( -e $l)
{
push(@loglist,$l);
$d++;
$l="$logdir/poclbm$d.log";
$devices{$l}=$d;
}
# 2) Make an exhaustive list of days, by an initial pass of all files.
my %days;
for $l (@loglist)
{
print "Opening $l\n";
open(L,$l) or next;
while ()
{
chomp;
my @a=split(/[ ,]+/,$_);
$a[0]=~m:^[0-9/]{10}: or next;
my @b=split('/',$a[0]);
my $b=join('-',@b);
$days{$b}=1;
}
close L;
}
# 3) now open all the log files, read into memory a day at a time, sort and output as a single stream.
# read just one days worth of data from each file.
#
my $matching=0;
for my $date (keys %days)
{
my $dateo=$date;
$date=~s:-:/:g;
my @data;
for $l (@loglist)
{
$d=$devices{$l};
print "Opening $l device $d\n";
open(L,$l) or next;
while ()
{
chomp;
m:^[0-9/]{10}: and !m/$date/ and $matching=0;
if (m/$date/)
{
s/,/ $d,/;
push(@data,$_);
$matching=1;
next;
}
if ($matching)
{
$data[-1].=" ".$_ if $data[-1] =~ m:^[0-9/]{10}:
}
}
$matching=0;
close L;
}
print "Sorting for $date\n";
@data=sort { $a cmp $b } @data;
$"="\n";
$dateo=join('-',reverse split('-',$dateo));
$outfile="$logdir/$dateo.log";
open(LL, ">>$outfile") or die "Cannot open $outfile";
print LL "@data\n";
close LL;
print "Output done for date $date to file $outfile\n";
}
unlink @loglist;
}
If you find this useful, please bitcoin me! 187PquUCdXRHvQgNc5e7GUnkX8ZeNxMx62
Even 0.001 bitcoins would let me know you found it intresting!!
But even if you do not to bitcoin me, would like to hear that you found it useful anyway!