Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
1  
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
add comment

Your Answer

 
discard

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.