I have no idea how you managed to find the path of a file on your server by searching Google. I suspect the value you're using could be wrong. One way of getting this information is by uploading the following script to your site (call it whereami.php
, for example) and accessing it with a web browser (at yoursite.com/whereami.php
):
<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>
To run a PHP script from the command line (or a cron job), you need to know where your PHP application is located. /usr/bin/php
is usually a safe bet, but your web host will be able to tell you. Pass the script you want to run as a command line argument, e.g.:
/usr/bin/php /path/to/my/html_docs/abc.php >/dev/null
The >/dev/null
at the end of this line simply discards the output of the PHP script so it isn't emailed to you every time.
Another approach (and one I would actually recommend) is to get your web server involved. That way you can ensure that the script is run in exactly the same environment as the PHP scripts in your website. For example, using the curl
utility:
/usr/bin/curl http://yoursite.com/abc.php >/dev/null