PHP- file() not working in cron?

Status
Not open for further replies.

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Hey. I have a file that is run by my crontab once every 24 hours. It simply loads up a list of values and changes my site to reflect those values.
It works fine.

However, when run under the crontab, it generates the following error:

Code:
[/FONT]Warning:  file() [function.file]: URL file-access is disabled in the server configuration in **SCRIPT URL** on line 3
Of course, this leads to another error:
Code:
Warning:  file([URL="http://www.nationstates.net/cgi-bin/regiondata.cgi/region=antarctica"]**URL**[/URL]) [function.file]: failed to open stream: no suitable wrapper could be found in **SCRIPT URL** on line 3


Like I said, the errors only occurs when the file is run on the cron, and works perfectly if I simply load up the script in my browser.

Here's the first three lines of the script. Of course, as above I have replaced the actual URL with **URL**. The URL should not make a difference to the file() problem.
Code:
#!/usr/local/bin/php -q
<?php
$file = file ("**URL**");

What's really confusing me is that this script used to work. Then all of a sudden without any changes to it, it stopped working!)
Am I doing something wrong, has the server/permissions changed or something else?
 

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
So you're certain that opening the PHP file in the browser works with no errors, and the issue only occurs when the script is run by the Cron Daemon? I need to confirm this before we go any further.

-Luke.
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Yes, I have run the file in my browser, and outputs exactly what it should. Never seen an error when I run it myself.

However, when the Cron Daemon sends me the output of the run in email, it gives me the errors previously mentioned.
Edit:
Oh, my PHP configuration is Intermediate, if that helps :)
 
Last edited:

Jarryd

Community Advocate
Community Support
Messages
5,534
Reaction score
43
Points
48
I have alerted an admin of your issue, you should receive a reply shortly.
 

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
Can you use local file access? /home/scoochi2/folder/path/of/the/script for example.
 
Last edited:

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Can you use local file access? /home/scoochi2/folder/path/of/the/script for example.

Affirmative. That's how I run the cron.
It does run the script, although it can't get the information it needs -through file()- and then continues, acting without the information it needs to.


But yeah, it does run it.
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
oh. Well I use file() from an unrelated url.
It's a brief XML feed that I'm fileing :)
Sorry if I didn't make that clear previously.

done via the normal file("http://etc...");
 
Last edited:

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
Instead of php -q or /usr/bin/php in your cron path, use php-cron for the binary.

-Corey
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
I think that's solved it... it ran the first time and got me disabled for high usage. (???)
The second time it ran, it did it perfectly!

Brilliant. Thanks to all :)
 
Last edited:
Status
Not open for further replies.
Top