in reply to Re^2: Converting a parallel-serial shell script
in thread Converting a parallel-serial shell script

What if you simply spawn children to do the conversions and then have the parent import the results into the database as each one completes its task? There is only one parent, so the imports will be nice and sequential.

You don't need locked files if you use files creatively: Have the children put their results into a results###.tmp file. After they have finished, they can rename the file to results###.tsv

The parent simply waits for the .tsv files to appear, and the files are complete as soon as they appear.

Or, if the file rename is not atomic enough, you can instead create a flag file results###.tsv.done after the .tsv is finished. The .tsv will be completed and closed and completely ready to be imported before the flag file appears

  • Comment on Re^3: Converting a parallel-serial shell script