Cron jobs and CURL php module

Posted on 2004-08-24
Last Modified: 2012-06-27
I have a PHP function that uses CURL. When I load the page in my browser, all code is being executed like it should. However, when the script is called as a cron job, I get a cron result mail with following error:

"This SMS API class can not work without CURL PHP module!"

Is this CURL module not loaded when I run it as a cron job?
This is how I call (all) cronjob pages:

"/usr/bin/php /home/puca/public_html/include/script.php"

(all other scripts work this way, only CURL gives an error..)
Question by:puca01
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +5
LVL 48

Expert Comment

ID: 11883908
do a /usr/bin/php -m and see if the curl-module is available.
If not maybe you could load it try

if(dl('')) { echo "curl loaded";} else {echo "not loadable";}

and watch teh output on the command-line. If it is notavailable you have to recomplie the CLI-php

Author Comment

ID: 11884059
It is not in the module list.
I tried the code and got this warning:

<b>Warning</b>:  dl(): Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20020429/' - /usr/lib/php/extensions/no-debug-non-zts-20020429/ cannot open shared object file: No such file or directory in <b>/home/puca/public_html/testcurl.php</b> on line <b>3</b><br />
not loadable

I'm not able to recompile because it is a shared hosting. But how come CURL works when I acces the script with a browser?
Can't I just call the script an other way or something like that?

Author Comment

ID: 11885201
Points now 125 for the one that can solve this
(and again: I cannot recompile, it needs to be doen with the CURL currently working for browser acces)
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Expert Comment

ID: 11885512
Perhaps you can compile the module yourself, store it in your account, and then use the absolute path to the module.  I have no idea if that will work.
LVL 48

Expert Comment

ID: 11885620
No absolute path will work for dl
file /usr/share/extensions/no-debug-non-zts-20020429//home/xyz/ not found

but you could compile a php on a linux box with the modules you need, upload that binary and then use that binary for your cron-job
e.g /home/puca/bin/php

maybe you can even compile that php on the box for your pages if you have shell-access, so all libraries will match.

Author Comment

ID: 11885642
I'm not an expert in linux so I don't know if I can do that.
Is there anybody who can explain to me why the thing works when i load it in a browser and not with commandline execution?

Or just how i can simulate browser acces with a commandline execution?

Expert Comment

ID: 11886741
Try other methods of doing PHP cronjobs like:

or other methods include..



lynx --dump >/dev/null

Expert Comment

ID: 11887149
If this /usr/share/extensions/no-debug-non-zts-20020429//home/xyz/ won't work, maybe you can do

But if you have Lynx, you could do as LiquidIce911 suggested.

Author Comment

ID: 11887962

got these error messages:
/bin/sh: line 1: /usr/bin/lynx: Permission denied
/bin/sh: line 1: /usr/bin/wget: Permission denied

Is there an easy way to get the lynx binary so I can put it in my own folder and with sufficient rights?


This was just a warning when i ran this line of code:
if(dl('')) { echo "curl loaded";} else {echo "not loadable";}

So I'm not referring to that path, the server locates it itself.

Expert Comment

ID: 11888571
I've run into this before.  I think I can help.

First run phpinfo(); from a browser. Under configuration / PHP Core, find include_path.  Copy the value listed.

Then at the top of your script add this line...

    ini_set("include_path", "whatever/path/phpinfo/showed;maybe/more/then/one");

When your script runs from the browser, apache is setup and knows where to find everything.  When it's run from the command line you sometimes find that your running a whole different version of php that may not have been configured the same.  If you really want to debug things, you can check the results of phpinfo when run from the browser, compared to when run from cron.

See for a user comment showing a small script to email phpinfo back to you.

As far as making lynx or wget work, if you have read permission, try this...

cp /usr/bin/lynx .
cp /usr/bin/wget .
chmod +x lynx
chmod +x wget

You now have the binaries in your local directory and ready to execute.  It may not work, depends on the file permissions your admin has setup.

Author Comment

ID: 11894747
I've tried what you said about the include_path, however it doesn't work. I still get the same error:
This SMS API class can not work without CURL PHP module!

I alerady tried copying the binary, but I do not have permissions for that..

I have found a workaround myself: I call a script that does a http request to the other page. It works this way although it's not a professional solution :-)
LVL 18

Expert Comment

ID: 11895034
As for the reason that this is happening, there are two "versions" of PHP.  One here is compiled into apache, and loads once when apache loads, and is called once for each page loaded.  The other is /usr/bin/php which is loaded each time you call it.  I have to wonder if the hosting company knows what they're doing if the two versions are compiled with different modules.
LVL 20

Expert Comment

ID: 12549925
PAQ it - the last comment of the asker is a solution.


Accepted Solution

modulo earned 0 total points
ID: 12574374
Closed, 125 points refunded.

Community Support Moderator
Experts Exchange

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question