3

I want to get the pid of a php script:

php /var/www/html/test.php

I have a couple of other php scripts running as well, for instance

php /var/www/html/hello.php
php /var/www/html/world.php

When I run pidof -s -x php /var/www/html/test.php, it randomly gives me the pid of any of the 3 running scripts. I think it's because it's only seeing the php after -x and ignoring the rest. I tried it with quotes and I didn't get any result at all.

pidof -s -x 'php /var/www/html/test.php'
  • What you are actually asking pidof to do is to give you a single result (-s), also checking for scripts (-x), of either "php" or "/var/www/html/test.php". I suspect you are assuming pidof will AND the results, which it doesn't. Removing "php" from the command line is probably more what you want. – Drew Bloechl Feb 7 '11 at 21:59
  • I tried that and that didn't work either. – gAMBOOKa Feb 8 '11 at 7:26
7

Give this a try:

pgrep -f 'php /var/www/html/test.php'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.