freephoneid Posted February 23, 2009 Share Posted February 23, 2009 Hi, I've a command line PHP file, say abc.php Now, my web application file needs to check if abc.php is running or not. How can I do that? Basically, I want to check if abc.php is running or not. How can I do it from another PHP which will be invoked through web based GUI which is using Apache? Thanks! Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/ Share on other sites More sharing options...
trq Posted February 23, 2009 Share Posted February 23, 2009 Depends on your os. On Linux I would grep ps. eg; ps aux | grep 'abc.php' Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/#findComment-769637 Share on other sites More sharing options...
freephoneid Posted February 24, 2009 Author Share Posted February 24, 2009 Hi, I think I did not clearly mention it in the question....I want to check this through PHP program. How can I do it in PHP?? Is there any PHP command which can tell me if another PHP is running or not? btw, I'm using Linux Thanks! Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/#findComment-769648 Share on other sites More sharing options...
samshel Posted February 24, 2009 Share Posted February 24, 2009 thorpe meant use a combination of exec and this command like exec("ps aux | grep 'abc.php'", $return); print_r($return); Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/#findComment-769652 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 Use exec (or related functions) to execute the shell command I posted via php. Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/#findComment-769653 Share on other sites More sharing options...
freephoneid Posted February 24, 2009 Author Share Posted February 24, 2009 I think I found the better approach....I would use posix_kill & getmypid command to check if its running....thanks anyways.... Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/#findComment-769658 Share on other sites More sharing options...
samshel Posted February 24, 2009 Share Posted February 24, 2009 i think getmypid will give u process id of the current script instance that u r running, if u run the same script through another terminal, you will not get pid of that. not sure, but u can confirm. just check if this is what u want. Link to comment https://forums.phpfreaks.com/topic/146606-solved-how-to-check-if-command-line-php-is-running-or-not/#findComment-769660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.