Reputation: 12064
How can I understand this part of script? Invoking ps h -fwC ifmFuseHandler
gives this output:
DRBimg:/tmp # ps h -fwC ifmFuseHandler
insite1 29149 1 0 11:57 ? Ssl 0:00 ifmFuseHandler -o allow_other /opt/insiteone/fuse-mount
I am particularly interested in what condition the ifmFuseHandler starts?
Here is the complete script (some excerpt form):
# START IFM
if [ $MYTYPE = "ifmFuseHandler" -o $MYTYPE = "ALL" ]
then
# IF A PROXY
if [ $PROXY -eq 0 -a $DOIFM -eq 1 ]
then
# Make sure the fuse module is loaded
FUSE=`lsmod | grep fuse`
ret=$?
if [ $ret -ne 0 ]
then
/sbin/modprobe fuse 2>/dev/null
fi
FOUND=1
#PID=`df | awk '/ifmFuseHandler/ {print $1}'`
#PID=`ps -ef | grep -v 'awk' | awk '/ifmFuseHandler/ { print$2 }'`
PID=`ps h -fwC ifmFuseHandler | awk '/ifmFuseHandler/ { print$2 }'`
if [ "x$PID" = x ]; then
msg "Starting ifmFuseHandler..." $MSG_ALL
su - $USER -c "cd $DIR_INDEX;ifmFuseHandler $IFM_SINGLE_THREAD -o allow_other $IFM_MOUNT"
else
msg "ifmFuseHandler already running! PID=$PID" $MSG_ALL
fi
fi
fi
Upvotes: 0
Views: 1264
Reputation: 14376
PID=`ps h -fwC ifmFuseHandler | awk '/ifmFuseHandler/ { print$2 }'`
gives you the PID of ifmFuseHandler
if [ "x$PID" = x ]; then
tests whether a PID was returned; if not, the ifmFuseHandler is started, otherwise the message is printed that it is already running
myself, I would run
PID = `ps -el|grep -v grep|grep ifmFuseHandler|awk '{print $2}'`
Upvotes: 1
Reputation: 246807
It's just using ps's -C option. Compare
ps h -fwC ifmFuseHandler
with
ps h -fw
in a shell.
Upvotes: 1