Hi
I'm running a program many times with differents input.
I mean that i run my_prog with some parameters and i wait till the end, then i start again another simulations with some others differents parameters.
Is possible to make it automatic with a script bash.
Maybe i need some function to check if the program has completed its task.
thanks
D.
Sorry for the post. I've already found a solution.
We can use the pidof function. It works like:
if [ (pidof process_name) ] then
echo "It's already running"
else
echo "Not running"
is like you say xD
if pidof $1
then
echo "Is runnig"
else
echo "Is NOT runnig"
fi
Any reason why you wouldn't use "wait" ?
I'm assuming from what you say the program is running in the background, hence the issue with regards to knowing what it's finished .. how about something like;
for i in `cat parameters`
do
echo "Testing with $i"
time ./my_prog $i
wait $!
done
Depending on your parameters you'll probably need something a little more complete than "cat parameters", but in principle this will wait for my_prog to finish even if it backgrounds ..
Or .. for a batch in parallel ..
list=""
function me()
{
./my_prog $1
list="$list $!"
}
for i in `cat parameters`
do
echo "Testing with $i"
time me $i
done
wait $list
'Course if they all finish around the same time, the output from "time" might be interesting to interpret ...