David542
David542

Reputation: 110163

How to tell when a background job is 'done'

Let's say I run the following command:

$ find /mnt/folder1 > file2.csv & find /mnt/folder2 > file2.csv &

Is there a way to signal when these jobs are done? Or do I need to poll something like $ jobs or $ ps aux in order to infer when they're done? What's the suggested way to handle this?

Upvotes: 0

Views: 324

Answers (2)

Ole Tange
Ole Tange

Reputation: 33685

Mark Setchell's comment spelled out:

$ find /mnt/folder1 > file2.csv &
$ find /mnt/folder2 > file2.csv &
$ wait

Upvotes: 1

pr0logas
pr0logas

Reputation: 693

It is hard to catch your commands unless you have a robust entity. In your case, you can find a PID of the process like:

pgrep find
12542

it will find all process ids of current find jobs. If there are none, you can assume that the jobs are done.

Upvotes: 0

Related Questions