Jump to content

Getting Process ID Number


Rhiknow

Recommended Posts

How do I get the process id number into my PHP code.

 

I'm running a 'tail -f' command to monitor a file. How do I kill the tail process once I'm finished with it? I've just discovered a whole load of tails running when I run 'pgrep tail'!

 

$command="tail -f ".$file_being monitored." 2>&1";
$handle=popen($command, 'r');

while(!feof($handle))
{
   //monitor the file, take actions etc.

 

Any help would be much appreciated.

 

Thanks in advance.

Link to comment
Share on other sites

Thanks for the suggestion. I tried killing the php process, yet the 'tail' remains open.

 

If I do a 'pgrep tail' and then manually kill that process, the connection is broken. kill -9 getmypid() doesn't work as this kills the PHP.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.