I have following in my script
ACTIVE="$(pgrep -a crawl | wc -l)"
echo $ACTIVE
pgrep -a crawl | wc -l
echo is giving me 3, and last line is giving me 2.
Does anyone knows why?
Thank you
I have following in my script
ACTIVE="$(pgrep -a crawl | wc -l)"
echo $ACTIVE
pgrep -a crawl | wc -l
echo is giving me 3, and last line is giving me 2.
Does anyone knows why?
Thank you
I assume that the script is called 'crawl'. In that case, the higher number in $ACTIVE is due to the additional process that runs the command inside $(...). I'd expect the numbers to be 2 and 1 instead of 3 and 2 though. There must be another process called 'crawl' on the system when the script is running.