xml - Does it matter if I use relative or absolute path's when running a php script via cron? -
i working on script attempting automate via cron. running script via terminal fine, when attempt run script crontab, getting issues.
part of script loads , validates , xml file via domdocument::loadxml() , domdocument::validate() , php throws error when attempting validate stating:
failed load external entity: /linuxuser/homefolder/my_dtd.dtd
within xml file, dtd set to:
../../../../../../../my_dtd.dtd
is there misconfiguration of server or more wrong php code @ point? seems grab linux home directory rather path relative xml file. wondering if else has seen issue or point me in right direction. thanks.
quoting php documentation differences in cli usage (command-line interface):
the cli sapi not change current directory directory of executed script!
when php scripts run via cron, executed on user's home directory. can either replace relative path references used script absolute, or place on start of script:
chdir(dirname(__file__)); # php 5.2.x , below # or chdir(__dir__); # php 5.3+
Comments
Post a Comment