What will the workflow be if we execute the scripts as follows:

script1 &
script2 &

I need to run the script3/4 after completion of script 1/2.

  • You can add a wait command before script3. – FedonKadifeli Jul 9 at 12:10
  • if code cleanliness and multithreading isn't all that much of an issue, script 1 can call script 2 and script 2 can call sript 3, 4 and 5 – tatsu Jul 9 at 12:13

The workflow is unpredictable as asked like this: script3 could finish before script1 or script2 are finished unless there is logic in script3 to test the state of script1 and script2. Same for script4: all it tells right now is that it will start after script3 is done but script 1 and/or script2 could be done or still be running unless there is logic in script4 to test the state of script1 and script2.

This will run them sequentially in background:

(script1; script 2; script3; script 4) &

or if 1/3 and 2/4 are independent:

(script1; script3) &
(script2; script4) &

nohup at the beginning if you don't want it to stop when you exit command line

If would execute the scripts from within the other scripts though. Cleaner and nobody will forget to run the 2nd script after the 1st one has finished.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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