I have a situation where I need to:
- Do some preamble setup in Script A
- Start Scripts B, C, D and E together, so they run concurrently
- When all four scripts have exited, do some cleanup in Script A
At the moment I have run flags in scripts B - D which set whether or not the script is still running, and after firing off the four scripts, script A sits in a wait loop checking these flag files.
Is there a better way to do this?
The background is this is a backup script for an AIX server using snapshots - script A takes the JFS2 snapshots on the file systems we wish to backup (they all need to be done at the same time, as we have related data distributed across different filesystems - this cannot be changed), scripts B - D do the actual backups of these filesystems from the snapshots (three rsyncs to a different server, and one tape backup), and then script A removes the snapshots once all the file copies (including to tape) are completed.
With bash, you can do this: