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's the pid of the main script<br>
<br>function do_sleep {<br> # sleeps in certain conditions<br> if [ <condition> ]; then sleep 2m; fi<br>}<br><br>for poo in $( <generated list of crap>); do<br> psql -c "vacuum freeze poo;"<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's not making sense in the psql call case. Could run a ps |grep <cmd> and strip out the extra or even pidof <cmd> 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>