Can't seem to get this to work. I have a PHP command-line script that I would like to execute by invoking it from a web page. Basically, I want to be able to trigger the start of this process by hitting a php page on the webserver. Ultimately, I would capture and store the PID, so that I could hit another page and terminate the script (it's a looping job that is doing something for me in the background). It may seem dumb, but indulge me. There's a reason I want to do it this way.
What I have running right now doesn't seem to work. No matter how I invoke the command-line script from within my PHP page, it doesn't seem to execute the command, or give any feedback as to why the process isn't starting. Any ideas?
Here's a basic code example:
Code:
Code: Select all
<?php
// The webpage code
`/usr/local/bin/php /home/test.php`;
//
// no output
// Also tried:
// exec ("/usr/local/bin/php /home/test.php");
//
// no output
// system ("/usr/local/bin/php /home/test.php");
//
// results in "Could not open input file: /home/test.php. "
?>
Code: Select all
<?php
// the CLI code
while (1)
{
// .... do something
}
?>
Any ideas why the command-line program won't start? Is it because the Apache server is running as "nobody" and that user doesn' have permission to run the php command? If so, what steps should I take to allow this - it's a server running on an intranet, so security is not a huge concern.