Re: Referencing files in cron jobs versus format when running from URL
| From: | brian | Date: | Sat, 02 Aug 2008 15:58:15 +0000 |
| Subject: | Re: Referencing files in cron jobs versus format when running from URL | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277619@lists.php.net to get a copy of this message | ||
ioannes wrote:
I have a file that works from the URL like: www.mysite.com/cronjob.php and this file includes references to uploaded files like this: /home/mysite/public_html/dir/subdir/filename.xml and this is used in functions like filemtime(). The uploaded files are found on the server using the above path in the code of the php file. However, when I cron the php file from the server using: /ramdisk/bin/php4 -q /home/mysite/public_html/cronjob.php (using the server cPanel Cron Manager Linux command type set up page), the php file does not find the uploaded files, presumably because the above format of /home/mysite/public_html/dir/subdir/filename.xml needs to be a different path. This must be familiar to many, can you help in suggesting change in path required?The path to your file doesn't need to be changed. It is where it is. Do you have the path hard-coded in the script? Or, are you resolving it using the $_SERVER or $_ENV array? When cron executes your script, it's doing so directly (ie. CLI) rather than through httpd, so you'll find that the environment is a little bit different. Try running a CLI-executed phpinfo() script and compare to what you'd normally get when hitting the same script through a browser. If you don't have terminal access, run it with cron and have it capture and mail the output to you. b