OK, I've got the following script:
and if I do a 'ps -ef' I only have 1 process with '/usr/sbin/cron', so I run my script:
and it returns 2 PID's.
If I run the same thing myself:
I only get 1 PID.
I'm pretty sure something is getting screwed up in the line with the ` characters:
How can I fix it to only return a single PID?
Code:
#!/bin/bash
EXEC_NAME=$1
echo "$EXEC_NAME" | grep "/" > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
EXEC=`echo "$EXEC_NAME" | sed "s:\(.\)\(.*\):\2:"`
echo "EXEC = $EXEC"
PID=`pgrep -f $EXEC`
else
PID=`pgrep -x $EXEC_NAME`
fi
echo "PID = $PID"
and if I do a 'ps -ef' I only have 1 process with '/usr/sbin/cron', so I run my script:
Code:
./check.sh "/usr/sbin/cron"
If I run the same thing myself:
Code:
pgrep -f "/usr/sbin/cron"
I'm pretty sure something is getting screwed up in the line with the ` characters:
Code:
PID=`pgrep -f $EXEC`