Running php scripts that include relative paths with cron

  |   By  |  One Comment

I recently had a problem running a php script which had an include() in it using cron. It worked fine in normal testing, but not as a cron job.

The reason is that when browser testing the working diorectory is the script’s directory. Cron uses the php location as the working directory, so the relative paths won’t be the same.


Either use absolute paths or change the working directory.