Rhiknow Posted July 9, 2009 Share Posted July 9, 2009 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 https://forums.phpfreaks.com/topic/165397-getting-process-id-number/ Share on other sites More sharing options...
ignace Posted July 9, 2009 Share Posted July 9, 2009 <?php print getmypid(); ?> Link to comment https://forums.phpfreaks.com/topic/165397-getting-process-id-number/#findComment-872302 Share on other sites More sharing options...
Rhiknow Posted July 9, 2009 Author Share Posted July 9, 2009 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 https://forums.phpfreaks.com/topic/165397-getting-process-id-number/#findComment-872401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.