Re: Referencing files in cron jobs versus format when running from URL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux