Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a situation where I need to:

  1. Do some preamble setup in Script A
  2. Start Scripts B, C, D and E together, so they run concurrently
  3. 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.

share|improve this question
up vote 7 down vote accepted

With bash, you can do this:

init # do the preamble setup of script A

scriptB & # start in background
scriptC & # start in background
scriptD & # start in background

wait # wait for all background jobs to finish

cleanup # do the cleanup part of script A
share|improve this answer
Thats exactly what I want, thanks! – Moo Aug 5 '09 at 8:48
you're welcome :) – Balázs Pozsár Aug 5 '09 at 8:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.