Difference of running scripts manually or with a cronjob

Solution 1:

Running from cron doesn't pull in your shell configuration files (~/.bashrc or ~/.profile or /etc/profile) Is it possible there are environment variables defined there that are affecting your job? Try sourcing your profile files manually at the start of your script. (. /path/to/profile)

Solution 2:

That's a very common problem with cronjobs--you simply cannot assume your environment variables, paths, etc. What I like to do is to have a cronjob that does "set > /tmp/set" so you can see exactly what you're going to have from the point of view of the cronjob. This way you can compare the assumptions your script makes, and what adjustments need to be made.

Solution 3:

My simple solution is to call the php file with LYNX Assuming you have an http server running

lynx http://127.0.0.1/document.php