Sample Header Ad - 728x90

using wait (bash posix) and fail if one process fails in a script

3 votes
1 answer
1432 views
I am writing a script that executes a bunch of commands in the background all at once then waits for them to all finish:
#!/bin/sh -fx
./p1 &
./p2 &
./p3 &
./p4 &
./p5 &
wait
The problem is that if one or more of these processes fail, it just keeps going. How can I execute all of these commands at the same time and check if one or more fail?
Asked by user567972 (31 rep)
Apr 5, 2023, 02:49 PM
Last activity: Apr 5, 2023, 03:29 PM