We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

CRON Jobs - problem with PHP script


toineg
09-02-2015, 13:04
Hello Jez,

Could you give us the relevant domain name?

Jez
02-02-2015, 10:20
Hello everyone,

Here is my problem:
I have created several scripts to be run though CRON, in PHP. Within the script, I actually use two functions calling external files (also located on the server): "include" and "file_get_content". The script sends status email with some info extracted from my database. I use "include" to open the database connection and "file_get_content" to get the email design (in an HTML file).

When I run my script in a browser, everything goes well.
As soon as I add it in CRON, it doesn't work anymore. It fires the email (so the CRON actually runs the script), but the email is empty (so I assume that either the DB connection isn't made, or the email structure isn't called, or both).

I have tried to change the way I access these files using "www/folder_name/file_name", but it didn't solve the problem.

Right now, to test the script, I've just set the CRON to fire every hour. Each hour, I see the result, modify a bit my script, and wait for another. Not so efficient, right?

So here are my questions:
1. Is there a better way to test my script than wait for an hour each time? As it works fine in my browser, testing it through browser isn't the solution either.
2. Do you know why my script isn't working?

Other problem: I never receive the logs by email even though I've activated the option.

Any help?

Thank you in advance!