I have a small script that loops through all files of a folder and executes a (usually long lasting) command. Basically it's
for file in ./folder/*;
do
./bin/myProgram $file > ./done/$file
done
(Please Ignore syntax errors, it's just pseudo code).
I now wanted to run this script twice at the same time. Obviously, the execution is unnecessary if ./done/$file exists. So I changed the script to
for file in ./folder/*;
do
[ -f ./done/$file ] || ./bin/myProgram $file >./done/$file
done
So basically the question is:
Is it possible that both scripts (or in general more than one script) actually are at the same point and check for the existance of the done file which fails and the command runs twice?
it would be just perfect, but I highly doubt it. This would be too easy :D If it can happen that they process the same file, is it possible to somehow "synchronize" the scripts?
xargswith the-Poption available, see this question.done/$filemarkers seem a little likemaketargets to me.xargsor GNUmakeor some version ofparallel, then there is no need to reinvent this particular wheel.