domenica 4 maggio 2014

Script to wait until execution of a background process has ended.

Hi all

Today a simple script. 
If you need execute a process (for example script1.sh) and wait his termination to start execution another process (for example script2.sh) here a simple solution :

#!/bin/ksh

echo ' Start script1.sh '

./script1.sh > /dev/null &
VAR=$!
echo 'PID ' $VAR
wait $VAR

echo 'Finish script1.sh' 
echo ' Start script2.sh '

./script2.sh > /dev/null &
VAR=$!
echo 'PID ' $VAR
wait $VAR


echo 'Finish script2.sh' 

An important command for this application is wait which pauses until execution of a background process has ended.

Stay Tuned.

Nessun commento:

Posta un commento

Check Mid Year Objectives

Hi all Today middle year check of my 2026's goals. 1. ENGLISH Improve listening comprehension (So and So)   See at least one or two film...