On Fri, 19 Aug 2005, Klaus wrote:
> Is there a way to extract a PID out of cfengine while it runs? That
> would make the kind of code loop used above less dodgy.
we do something similar in our startup script (though I cannot claim credit
for this bash bashing). note success() and failure() are redhat-isms
# manual callout for cfagent; let it only run for upto 2min
echo -n "cfagent execute: "
/usr/sbin/cfagent -q > /dev/null 2>&1 &
RETVAL=$?; subpid=$!
if [ $RETVAL -eq 0 ]; then
maxtime=120
while kill -n 0 $subpid 2> /dev/null; do
if [ "$maxtime" -lt 1 ]; then
kill -n 9 $subpid 2> /dev/null
failure "cfagent boot timeout"
RETVAL=1
break
fi
sleep 1
maxtime=$((maxtime-1))
done
kill -n 0 $subpid 2> /dev/null || [ "$maxtime" -gt 0 ] && \
success "cfagent boottime execute"
The assumption is that a reasonable cfengine run will never take two minutes
to complete.
--
- Eric Sorenson - N37 17.255 W121 55.738 - http://eric.explosive.net -
- Personal colo with a professional touch - http://www.explosive.net -
_______________________________________________
Help-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-cfengine