cURL problem when run by cron job

Status
Not open for further replies.

walkhome

New Member
Messages
4
Reaction score
0
Points
0
I have a php script which calls on the curl library and runs fine when executed from the address bar.

When cron calls it, it returns the following error via email:
---------------------------------------------
Status: 302 Moved Temporarily
X-Powered-By: PHP/5.2.5

Set-Cookie: PHPSESSID=4257db6a00fc88b2568473867909418d; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
location:login.php
Content-type: text/html


Connected successfully on Wednesday 26th of March 2008 09:17:02 AM <bWed, 26 Mar 2008 09:17:02 -0500 /><bWed, 26 Mar 2008 09:17:02 -0500 /><br />
<b>Fatal error</b>: Call to undefined function curl_init() in <b>/home/walkhome/public_html/check_alerts.php</b> on line <b>91</b><br />
----------------------------------------------
My account details:
cPanel name: walkhome
Main domain: walkhomealert.x10hosting.com
Address of script: walkhomealert.x10hosting.com/check_alerts.php
Server: lotus
PHP: Ugraded to intermediate level several days ago.

I have checked for similar posts and although I found one it didn't offer any answers.

Any help greatly appreciated.
 
Last edited:

Corey

I Break Things
Staff member
Messages
34,550
Reaction score
205
Points
63
How are you executing the cron? What command?
 

walkhome

New Member
Messages
4
Reaction score
0
Points
0
I ran it through the standard option on the cPanel interface using the following command:

php -cron /home/walkhome/public_html/check_alerts.php

The php script it calls check a database and if certain conditions are met it sends an SMS message using the curl library. If the conditions are not met then it does not send a message, just runs some MySQL queries.

When the script does not have to send any messages, the cron job works fine, it only fails when it needs to send one by accessing the curl library.

I should also tell you that the script is running once a minute. I understand that this is far more frequently than many do, but it is not backing up databases or anything, it just checks a database a sends a text message if needed. Also, I figured that if the setting is there to do that you must not have a problem with that so long as it is not being abused, which is not my intent.

The high frequency is a requirement of the security service my project website is offering where people can set up alerts by text when the are walking home alone etc.

Hope this helps.
 

Corey

I Break Things
Staff member
Messages
34,550
Reaction score
205
Points
63
try php-cron /home/etc/etc/

We have a separate PHP for crons that you would need to use. I've asked Bryon to double check but he is away right now. If it is not php-cron I will update later with it.

Running the cron every minute could possibly get you suspended in the future depending on the load of the server since your account would be flagged from the constant use. Just a warning ;)

-Corey
 
Status
Not open for further replies.
Top