run another process after the background process is complete

Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
said i have looping script in file test.sh, i just want to running script "running_script2.sh" after the background process is complete, what i try like this, but it's not working .
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
wait
echo "running script2 ..."
bash running_script2.sh
its work when :
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
but its not efficient
bash background-process
add a comment |Â
up vote
2
down vote
favorite
said i have looping script in file test.sh, i just want to running script "running_script2.sh" after the background process is complete, what i try like this, but it's not working .
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
wait
echo "running script2 ..."
bash running_script2.sh
its work when :
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
but its not efficient
bash background-process
The first line of your example, theforstatement, should have the literal wordinbetweenidand the numerals.
â user1404316
Aug 13 at 3:59
ups, I forgot to add 'in'
â Anggoro Setiawan
Aug 13 at 4:10
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
said i have looping script in file test.sh, i just want to running script "running_script2.sh" after the background process is complete, what i try like this, but it's not working .
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
wait
echo "running script2 ..."
bash running_script2.sh
its work when :
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
but its not efficient
bash background-process
said i have looping script in file test.sh, i just want to running script "running_script2.sh" after the background process is complete, what i try like this, but it's not working .
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
wait
echo "running script2 ..."
bash running_script2.sh
its work when :
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
but its not efficient
bash background-process
bash background-process
edited Aug 13 at 4:11
asked Aug 13 at 3:19
Anggoro Setiawan
304
304
The first line of your example, theforstatement, should have the literal wordinbetweenidand the numerals.
â user1404316
Aug 13 at 3:59
ups, I forgot to add 'in'
â Anggoro Setiawan
Aug 13 at 4:10
add a comment |Â
The first line of your example, theforstatement, should have the literal wordinbetweenidand the numerals.
â user1404316
Aug 13 at 3:59
ups, I forgot to add 'in'
â Anggoro Setiawan
Aug 13 at 4:10
The first line of your example, the
for statement, should have the literal word in between id and the numerals.â user1404316
Aug 13 at 3:59
The first line of your example, the
for statement, should have the literal word in between id and the numerals.â user1404316
Aug 13 at 3:59
ups, I forgot to add 'in'
â Anggoro Setiawan
Aug 13 at 4:10
ups, I forgot to add 'in'
â Anggoro Setiawan
Aug 13 at 4:10
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
There is no semantic difference between
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
and
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
This demonstration script below runs little over 3s (you can time it) regardless of whether the condition command is true or false:
#!/bin/sh -eu
for i in 1 2 3; do
echo "sleep $i" > $i && chmod +x $i
done
if false; then
for i in 1 2 3; do
bash ./$i &
done
else
bash ./1 &
bash ./2 &
bash ./3 &
fi
wait
If you're still experiencing discrepancies, please post an mcve.
add a comment |Â
up vote
0
down vote
Don't know whether this is a right approach but I have used screen to run script
screen is a virtual terminal to run process in bg
for id in 1 2 3
do
screen -d -m bash script1.sh $id
done
wait
echo "running script2 ..."
bash script2.sh
screen -d -m will run the script and closes the screen after the script completes.
I cannot get the output of script1 in standard output while using screen so I used a file to store the output of script1.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
There is no semantic difference between
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
and
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
This demonstration script below runs little over 3s (you can time it) regardless of whether the condition command is true or false:
#!/bin/sh -eu
for i in 1 2 3; do
echo "sleep $i" > $i && chmod +x $i
done
if false; then
for i in 1 2 3; do
bash ./$i &
done
else
bash ./1 &
bash ./2 &
bash ./3 &
fi
wait
If you're still experiencing discrepancies, please post an mcve.
add a comment |Â
up vote
1
down vote
There is no semantic difference between
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
and
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
This demonstration script below runs little over 3s (you can time it) regardless of whether the condition command is true or false:
#!/bin/sh -eu
for i in 1 2 3; do
echo "sleep $i" > $i && chmod +x $i
done
if false; then
for i in 1 2 3; do
bash ./$i &
done
else
bash ./1 &
bash ./2 &
bash ./3 &
fi
wait
If you're still experiencing discrepancies, please post an mcve.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
There is no semantic difference between
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
and
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
This demonstration script below runs little over 3s (you can time it) regardless of whether the condition command is true or false:
#!/bin/sh -eu
for i in 1 2 3; do
echo "sleep $i" > $i && chmod +x $i
done
if false; then
for i in 1 2 3; do
bash ./$i &
done
else
bash ./1 &
bash ./2 &
bash ./3 &
fi
wait
If you're still experiencing discrepancies, please post an mcve.
There is no semantic difference between
for id in 1 2 3
do
bash running_script1.sh $id & (#complete 1 minute/looping)
done
and
bash running_script1.sh 1 &
bash running_script1.sh 2 &
bash running_script1.sh 3 &
wait
echo "running script2 ..."
bash running_script2.sh
This demonstration script below runs little over 3s (you can time it) regardless of whether the condition command is true or false:
#!/bin/sh -eu
for i in 1 2 3; do
echo "sleep $i" > $i && chmod +x $i
done
if false; then
for i in 1 2 3; do
bash ./$i &
done
else
bash ./1 &
bash ./2 &
bash ./3 &
fi
wait
If you're still experiencing discrepancies, please post an mcve.
answered Aug 13 at 14:31
PSkocik
17.2k24590
17.2k24590
add a comment |Â
add a comment |Â
up vote
0
down vote
Don't know whether this is a right approach but I have used screen to run script
screen is a virtual terminal to run process in bg
for id in 1 2 3
do
screen -d -m bash script1.sh $id
done
wait
echo "running script2 ..."
bash script2.sh
screen -d -m will run the script and closes the screen after the script completes.
I cannot get the output of script1 in standard output while using screen so I used a file to store the output of script1.
add a comment |Â
up vote
0
down vote
Don't know whether this is a right approach but I have used screen to run script
screen is a virtual terminal to run process in bg
for id in 1 2 3
do
screen -d -m bash script1.sh $id
done
wait
echo "running script2 ..."
bash script2.sh
screen -d -m will run the script and closes the screen after the script completes.
I cannot get the output of script1 in standard output while using screen so I used a file to store the output of script1.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Don't know whether this is a right approach but I have used screen to run script
screen is a virtual terminal to run process in bg
for id in 1 2 3
do
screen -d -m bash script1.sh $id
done
wait
echo "running script2 ..."
bash script2.sh
screen -d -m will run the script and closes the screen after the script completes.
I cannot get the output of script1 in standard output while using screen so I used a file to store the output of script1.
Don't know whether this is a right approach but I have used screen to run script
screen is a virtual terminal to run process in bg
for id in 1 2 3
do
screen -d -m bash script1.sh $id
done
wait
echo "running script2 ..."
bash script2.sh
screen -d -m will run the script and closes the screen after the script completes.
I cannot get the output of script1 in standard output while using screen so I used a file to store the output of script1.
answered Aug 13 at 4:46
Edwin Babu
13
13
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462211%2frun-another-process-after-the-background-process-is-complete%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The first line of your example, the
forstatement, should have the literal wordinbetweenidand the numerals.â user1404316
Aug 13 at 3:59
ups, I forgot to add 'in'
â Anggoro Setiawan
Aug 13 at 4:10