I have a bash script that performs a sequence of tasks. I would like to be able to get the pid of the individual tasks for probable kill needs.<br><br>For example:<br><br>#!/bin/bash<br><br>my_pid=$$  # get&#39;s the pid of the main script<br>
<br>function do_sleep {<br> # sleeps in certain conditions<br> if [ &lt;condition&gt; ]; then sleep 2m; fi<br>}<br><br>for poo in $( &lt;generated list of crap&gt;); do<br> psql -c &quot;vacuum freeze poo;&quot;<br> do_sleep<br>
done<br><br>So I need to be able to get the pid of the sleep and the psql. $! will give the pid of a backgrounded shell process but that&#39;s not making sense in the psql call case. Could run a ps |grep &lt;cmd&gt; and strip out the extra or even pidof &lt;cmd&gt; but all require putting things in a background state. <br clear="all">
<br>-- <br>-- <br>James P. Kinney III<br>Actively in pursuit of Life, Liberty and Happiness         <br><br>