[lug] checking bg processes' exit status

Hugh Brown hugh at math.byu.edu
Tue Mar 4 10:53:30 MST 2008


On Tue, Mar 04, 2008 at 10:26:04AM -0700, Nick Golder wrote:
> I have a bash script that is setting a series of processes in the
> background and I want to see what their exit codes are.  I have played
> around trying to find a way to do it and I haven't found a reliable way,
> yet.  Any suggestions?

You mean like using the $? variable (here's a quickie script example):

#!/bin/bash
grep "ETHTOOL_OPTS"  /etc/sysconfig/network-scripts/ifcfg-eth0 >&/dev/null
RESULT=$?

if [ $RESULT -ne 0 ]; then
 echo "ETHTOOL_OPTS=\"wol g\"" >>/etc/sysconfig/network-scripts/ifcfg-eth0
 ethtool -s eth0 wol g
fi


Hugh



More information about the LUG mailing list