Running php scripts that include relative paths with cron

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.

One thought on “Running php scripts that include relative paths with cron”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.