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

Goals 2025

 Hi all Today, first day of 2025 my goals for this year : 1. ENGLISH Improve listening comprehension  See at least one or two films in Engli...