Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • I don;t think it is possible after the parent script has ended unless you can capture the parent's PID. If you are launching the scripts, you could wrap them in something like pid$(foo.sh; echo $!) which will give you the PID of foo.sh so you can then use ps --ppid. Will that work?
    – terdon
    Commented Sep 6, 2013 at 18:27
  • 2
    Do the scripts have to run under the UID of the author user? If not, can you create a dummy user just for this purpose? You wouldn’t even need grep, just ps –udummy_user. Also, look at process groups. Commented Sep 7, 2013 at 2:08
  • This is more a type of workaround than a solution for your initial question: Open a new bash session. You can list all processes spawned from this shell using ps without any arguments (should be only bash and ps in the beginning). Start your script there. After it finished, wait until ps | wc -l reaches your expected value.
    – Tim
    Commented Sep 8, 2013 at 13:17