Wait for all processes with a certain name to finish (in bash)
Asked Answered
D

3

6

I would like to wait in linux (Ubuntu 11.10) for a load of processes to finish. Each of these processes has a different pid but the same name. Is it possible to do this?

EDIT:

Perhaps I should specify that I don't necessarily know what the pid are, just the process name.

EDIT:

Thanks for the answers; Kevin's seems to do what I want. However, it doesn't work in the specific application I have, so I've posted a more detailed follow-up question here.

Dives answered 7/11, 2011 at 15:39 Comment(0)
M
9
wait $(pgrep programName)

Ought to do it.

Mihalco answered 7/11, 2011 at 15:44 Comment(2)
Provided that no new ones spawn after the pgrep executes.Thulium
That requires that the process you want to wait for was started in the same shell you want to use the wait command in.Sext
J
3
wait $(pidof processname)

perhaps.

Jaehne answered 7/11, 2011 at 15:43 Comment(0)
C
1

As long as you have the pid of these processes:

wait $pid_of_process

That should do it.

Chargeable answered 7/11, 2011 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.