2

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

1
  • 2
    This happens consistently? You can run this more than once in a row and get those results each time? This isn't just a temporary process that died/finished between the two calls in whatever run of this you saw it? Commented Dec 3, 2014 at 14:44

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.