ocehb: (Default)
[personal profile] ocehb
Дан скрипт:

#!/bin/sh -e
action1
action2
action3

action${i} — некоторые существующие в системе программы, прописанные в $PATH. Известно, что action1 и action2 никак не зависят друг от друга и могут выполняться параллельно, однако action3 требуется, чтобы и action1, и action2 успешно завершили свою работу.
Что необходимо изменить в скрипте, чтобы распараллелить работу action1 и action2, но запускать action3 только после успешного завершения action1 и action2?



#! /bin/sh
action1 & ; pid1=$!
action2 & ; pid2=$!

wait $pid1 ; ret1=$?
wait $pid2 ; ret2=$?

[ $ret1 -eq 0 -a $ret2 -eq 0 ] && action3

exit $?

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

ocehb: (Default)
ocehb

January 2021

S M T W T F S
     12
345 6789
10111213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 11th, 2025 03:55 pm
Powered by Dreamwidth Studios