clientRestart()
{
./folding stop
./folding start
}
clientRestart()
{
./folding restart
}
ps -eo pcpu,pid -o comm= | grep -Ei "fahcore" | sort -k1 -n -r | head -4 | awk '{ print $1 } '
SiriusB said:Dead easy![]()
uncle_fungus said:Thats a very nice bit of scripting there![]()
A few comments if I may:
Code:clientRestart() { ./folding stop ./folding start }
can simply become
Code:clientRestart() { ./folding restart }
Your CPU usage check is good, except it could easily become confused if another process suddenly started using high CPU usage. For example if the smp client died on my machine at midnight, the script wouldn't work, as I run some very CPU intensive cron'd jobs at around that time.
With this in mind, you could use this addition, which filters the results of ps for anything containing "fahcore", so it will only show the CPU usage for fah related processes.
Code:ps -eo pcpu,pid -o comm= | grep -Ei "fahcore" | sort -k1 -n -r | head -4 | awk '{ print $1 } '
I would recommend that you also don't use relative paths for calling the folding script, since finstall doesn't need to be in the local directory, running ~/foldingathome/folding restart is safer if you want to use this as a cron job. (Also remember cron runs as root, so you'll have to actually enter the real home location rather than just ~).
$HOME/foldingathome/folding restart
If you want any help with the other items on your todo list (like a non finstall capability) you have but to ask.
shadow said:I agree the the script entry looks easy - but my personal experiance is if i 'play' with ubuntu I brake it.
Setting up Fahmon is 'surposed' to be easy - took me three weeks, 7 reinstalled and 45 mins of Uncles F's 1-2-1 time.
Maybe I can't follow instructions 'to the letter' that Linux needs, but losing 10h or even a WU is less hassle than being on standard units again.
Edit: that Fact that I even have two SMP cruncher is totally down to the hardwork you and UF have done (that and my 'I will make it work' mantra)
SiriusB said:Would usingbe acceptable? This would then remove the need for the vast majority of people to edit the script.Code:$HOME/foldingathome/folding restart
SiriusB said:Also, how do you get this script to work with cron? I spent an hour last night trying to get it working without any luck. All I did find out was that cron uses an sh shell and not bash... or something! I couldn't find a definitive answer to actually get around this/make it work.
crontab -e
0 * * * * root /home/user/fahcheck
SiriusB said:I would welcome any help and advice! Since I am one for doing things myself - gotta learn these things, right? - could you just give me a clue as to how to safely stop and start a non-finstall SMP client. [I did try to find the answer in finstalls folding script but that thing is a beast].![]()
killall -QUIT FahCore_a1.exe
if cpu usage is too low
kill fahcore_a1.exe
fi
if fahcore_a1.exe or mpiexec or fah5 is running
kill fahcore_a1.exe
kill mpiexec
kill fah5
fi
change to folding client directory
if fah5 exists
run fah5
else
uh oh
fi
fahcoreProcess="`ps -eo pid -o comm= | grep -iE "fahcore" | awk '{print $1}'`"
mpiexecProcess="blah blah | grep -iE "mpiexec" | blah blah"
fah5Process="blah blah | grep -iE "fah5" | blah blah
if [ fahcoreProcess != NULL || mpiexecProcess != NULL || fah5Process != NULL ]; then
killall -QUIT fahcoreProcess
etc
etc
fi
if CPU usage of fahcores is too low
killall -QUIT fahcore
fi
wait 20 seconds for cores to quit correctly
#if any processes are still running send them a nice end signal
fahprocesses="ps ax |grep -iEc "fahcore|mpiexec|fah5""
#normally this would give a value of either 7 or 8 (4xfahcore, 1xfah5, 1xmpiexec, 1xsh running mpiexec(sometimes), 1xgrep) if all the processes are still running. If none are running you'd get a value of 1 (grep).
if [ $fahprocesses -gt 1 ]
killall -QUIT fahcore
etc.
fi
wait another x seconds (possibly longer than 20 seconds)
#if there are still processes, kill them outright
fahprocesses="ps ax |grep -iEc "fahcore|mpiexec|fah5""
if [ $fahprocesses -gt 1 ]
killall -KILL fahcore
etc.
fi
launch fah5 again