I'm trying to execute a php script on my linux server whenever I view a different page. So far this is what put on that page:

<?php exec('php  /var/www/html/execute.php'); ?>

I am trying to be logical with how linux executes php and the path to the file I wish to execute. But this was a best guess.

So far it isn't doing anything, but I'm also getting no errors in the logs.

Any thoughts on the right way to execute a php file?

    You may need to specify the full path to php, something like:

    exec('/usr/bin/php /var/www/html/execute.php');
    

    However, I'm wondering if it would not be simpler to just include() the script?

      Write a Reply...