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'
Give this a try: