PDA

View Full Version : cant get F@H running on mandrake...


CrashOveride
05-21-03, 10:47 PM
it wont work...i looked at that big helpful thread in Alt. OS's and the chmod +x <FAHfilename.exe> thing wont work tells me: bash: syntax error near unexpected token `newline'

i want this machine running!

lol i also cant get BitchX to run work im so newb :-/ help me!!!:D

CrashOveride
05-21-03, 10:57 PM
lol i figured it out... boy do i feelstupid, i tried putting in the <> around the filename heheh im so lost iwth this linux thing :-/
now how can i make it autorunon startup?

Arkaine23
05-22-03, 12:58 AM
I haven't had any luck with that, short of writing a small program that starts folding up, and get that program to run at startup. The biggest block is that I use the Windows client on my Nix boxes and fold using WINE. But Wine won't auto-start for me no matter what I try.


You can open a new test file and stick this little script in there. You need to have Wine installed on your system. You'll have to define some of the variables, like $FoldDir to reflect the place in your file heirarchy where you keep the folding@home executable.

Winefold shell script by Arkaine:

#!/bin/sh
$FoldDir=/data/folding
# go to directory where windows client resides
cd $FoldDir
# launch wine with nice level 19 and windows client with advmethods and forceasm flags and send output to file
/usr/bin/nice -19 wine FAH3Console.exe -- -advmethods -forceasm > fold.log

#Note: You may have to remove the nice -19 part. It works in gentoo, but I can't get it to work like that in redhat. Set your own $FoldDir to reflect where your windows console client resides.


Note: You need to place the script in your PATH. For me a good spot is /home/username/bin. You also need to chmod +x the script so it will be executable. Then you can just type the name of the text file as if it was a regular command and you'll start folding.

Arkaine23
05-22-03, 01:14 AM
I have another script that overdoze wrote that uses the native linux client and no WINE. It can be made to run at startup. But I'm not familiar with Mandrake so I don't know if it uses a System V style for startup scripts or not. It requires that perl and awk are installed on your system, and does more than just fold. It also detects and deletes bad WU's (this is beta still), and it will pause folding when another application needs cycles and resumes when the load drops again (because some linux folding cores don't do this correctly). Its a little more complicated than the other script.

Perl script by overdoze:

# written by ptn on 11/04/02
# fix bug rename bad WU 11/12/02
# This program will start Folding gromacs and monitor the job. If the jobs seem
# hung up it will kill it and restart with no options i.e. tinker core and vice versa.
# If user run any program and use the cpu it will stop the job and continue on when
# user's job finish within 2 minutes. The waiting period loop between checks is
# around 2 mins, twice the sleep constant. One can also run the program with argument
# stop to kill folding process then exit the program.
# one should run the program like example below if c shell is the user's shell
# fold >& fold.log &
# if you decide to start this program automactically at boot up you could add the
# following line to the file rc.local
# su <folder user's name> -c "fold > /<fold_directory>/fold.log 2>&1"

# NOTE: user's normaly change the following constants: $FoldDir, $FAH3Console, $options
# and $sleep

# user's Folding command line options:
$options='-advmethods -forceasm';
# user's check time interval
$sleep = 30;
# user's minimum cpuload value, must be less than the set value it will start folding
$minld = 0.55;
# find hostname
$host=`hostname`;chop($host);
# user's Folding directory location , uncomment second line if dual cpus
$FoldDir="/data/$host";
$FoldDir2="/data/${host}2";
# user's maximum cpuload value, must be greater than the set value it will stop folding
if (-x $FoldDir2) {
$maxld = 2.3;
}else{
$maxld = 1.2;
}
# user's Folding program location
$FAH3Console="/home/troyw/bin/FAH3Console";
# initial value for stop flag
$stop=0;
#######################Do not edit below this line ######################################
if (! -x $FAH3Console) {
die "ERROR: can't find executable $FAH3Console\n";
}
if (defined $ARGV[0]) {
if ($ARGV[0] eq 'stop') {
system("kill `cat $FoldDir/fold.pid`");
&KillFold;
system("rm -f $FoldDir/core.*");
system("rm -f $FoldDir2/core.[0-9]*") if (-x $FoldDir2);
}else {
my $cmd = $0;
$cmd = $1 if ($cmd =~ m!/.*/([^ ]+)$!);
print "Usage:\n\t$cmd [stop]\n";
print "Example 1: To start smart folding process, type";
print "\n\t$cmd\n";
print "Example 2: To kill folding process and exit, type";
print "\n\t$cmd stop\n";
}
exit;
}

open(OUTFILE, "> $FoldDir/fold.pid") || die "ERROR: can't write to file $FoldDir/fold.pid\n";
print OUTFILE "$$";
close(OUTFILE);
$option = $options;
$killCount=0;
Begin:
$load = (&findLoad);
if ($load < $minld) {
#stop old hung up Folding jobs if exists.
&KillFold;
# check for bad Work Unit if job hung and clean the directory
if ($killCount > 1){
sleep ($sleep * 2);
my $curload = &findLoad;
if ($curload < $minld) {
&SearchBadWU($FoldDir);
&SearchBadWU($FoldDir2) if (-x $FoldDir2);
}
}
#start new Folding jobs
my $time = localtime(time);
print "Start Folding processes at: $time\n";
# print "load= $load , Invoking:\ncd ${FoldDir}; nice $FAH3Console $options\n";
system("\(cd $FoldDir; nice $FAH3Console $option\) &");
system("\(cd $FoldDir2; nice $FAH3Console $option\) &") if (-x $FoldDir2);
if ($option eq '') {
$option=$options;
}else {
$option='';
}
sleep $sleep;
}else {
my $time = localtime(time);
print "Waiting for load=$load to come down at: $time\n";
sleep $sleep;
$killCount=0;
goto Begin;
}
Inloop:
sleep $sleep;
$load = (&findLoad);
if ($load < $minld){
if ($stop) {
$stop=0;
&ContinueFold;
sleep $sleep;
}elsif ($stop==0) {
&KillFold;
goto Begin;
}
}elsif ($load > $maxld && $stop==0) {
&StopFold;
$stop=1;
sleep $sleep;
}
goto Inloop;
exit 1;

sub StopFold {
my $time = localtime(time);
print "STOP Folding processes at: $time\n";
my $ps = `ps -uxw | egrep FahCore | egrep -v grep | awk '{print \$2}'`;
$ps .= `ps -uxw | egrep FAH3Console | egrep -v grep | awk '{print \$2}'`;
@PS=split(' ',$ps);
foreach my $p (@PS) {
system("/bin/kill -s STOP $p");
}
}

sub ContinueFold {
my $time = localtime(time);
print "RESTART Folding processes at: $time\n";
foreach my $p (@PS) {
system("kill -CONT $p");
}
}

sub findLoad {
my $load;
open(INFILE,"< /proc/loadavg") || die "ERROR: Can't read file /proc/loadavg\n";
while(<INFILE> ) {
$load=(split(' ',$_))[0];
last;
}
close(INFILE);
return $load;
}

sub KillFold {
my $time = localtime(time);
print "Kill Folding processes at: $time\n";
my $ps = `ps -uxw | egrep FAH3Console | egrep -v grep | awk '{print \$2}'`;
$ps .= `ps -uxw | egrep FahCore | egrep -v grep | awk '{print \$2}'`;
my @PS = split(' ',$ps);
foreach my $p (@PS) {
#print "kill $p\n";
system("kill -9 $p");
}
$killCount++;
}

sub SearchBadWU {
my $foldDir=pop(@_);
my $logFile = "$foldDir/FAHlog.txt";
my $line=`egrep 'Protein:' $logFile`;
my @protein = split(' ',$line);
$line = $protein[$#protein];
print "Last Protein in $logFile is $line\n";
if ($line eq 'Protein:') {
my $time = localtime(time);
print "Try to delete bad WUs and restart Folding at $time\n";
my $timestamp = $time; $timestamp =~ s/ /_/g;
system("mv -f $foldDir/queue.dat $foldDir/queue.dat.$timestamp; mv -f $foldDir/work $foldDir/work.$tim
estamp;mv -f $foldDir/initial.pdb $foldDir/initial.pdb.$timestamp; mv -f $foldDir/machinedependent.dat $fo
ldDir/machinedependent.dat.$timestamp");
}
}

CrashOveride
05-22-03, 09:19 AM
holy wow.... so i need to get peral install that then compilethis and use some System V or similar thing to make it run on startup?

wow... ok ill try it this afternoon... (i just installed Linux last night and have never used it before so im still super newb...)

OSUmaxx
05-22-03, 12:08 PM
Originally posted by CrashOveride
holy wow.... so i need to get peral install that then compilethis and use some System V or similar thing to make it run on startup?

wow... ok ill try it this afternoon... (i just installed Linux last night and have never used it before so im still super newb...)

*nix will already read perl scripts, at least all of the versions I've used.

Another way to get it to start @ startup is to place the command in /etc/rc.local I believe.