473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

cron not working when calling php script with mysql on linux box

I was referred to this forum as this may be a php specific problem.
Some kind of configuration problem maybe.

I have some php files that connect to a mysql database and are run as
cron jobs.

The scripts work fine when run via the command line as root, but when
run via the cron they cause a mysql connection error.

Call to undefined function: mysql_pconnect()

I have found some info on this and tried many things but none of them
are working.

Does this have something to do with setting the appropriate environment
in php
script? I read something about that but am not sure how or what to do.

Please help!!!

Thank you!

Aug 28 '06 #1
3 2563
db******@isound.com wrote:
I was referred to this forum as this may be a php specific problem.
Some kind of configuration problem maybe.

I have some php files that connect to a mysql database and are run as
cron jobs.

The scripts work fine when run via the command line as root, but when
run via the cron they cause a mysql connection error.

Call to undefined function: mysql_pconnect()

I have found some info on this and tried many things but none of them
are working.

Does this have something to do with setting the appropriate environment
in php
script? I read something about that but am not sure how or what to do.

Please help!!!

Thank you!
Could be your environment, PHP setup or any of about a dozen different
things.

One big difference is the cron job is probably running under a different
user, with different privileges - both for MySQL and PHP. It could even
be using a different php.ini - depending on the environment set up for
that user.

Did you try asking your sysadmin? That's where I would start -
otherwise you may spend days trying to chase down all the various
possibilities.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 28 '06 #2

db******@isound.com wrote:
I was referred to this forum as this may be a php specific problem.
Some kind of configuration problem maybe.

I have some php files that connect to a mysql database and are run as
cron jobs.

The scripts work fine when run via the command line as root, but when
run via the cron they cause a mysql connection error.

Call to undefined function: mysql_pconnect()

I have found some info on this and tried many things but none of them
are working.

Does this have something to do with setting the appropriate environment
in php
script? I read something about that but am not sure how or what to do.

Please help!!!

Thank you!

I believe i have narrowed this down.

I ran the same identical script with phpinfo() in it from 2 different
locations.

1 I ran from the command line and 1 I ran from the crontab.

The one that i ran from the crontab didn't not have mysql support
enabled.

Looks like that is the problem!

Why are these different?
How do i compile that php version with mysql support?

I believe this should solve this issue.

Thanks!

Aug 28 '06 #3
db******@isound.com wrote:
db******@isound.com wrote:
>>I was referred to this forum as this may be a php specific problem.
Some kind of configuration problem maybe.

I have some php files that connect to a mysql database and are run as
cron jobs.

The scripts work fine when run via the command line as root, but when
run via the cron they cause a mysql connection error.

Call to undefined function: mysql_pconnect()

I have found some info on this and tried many things but none of them
are working.

Does this have something to do with setting the appropriate environment
in php
script? I read something about that but am not sure how or what to do.

Please help!!!

Thank you!

I believe i have narrowed this down.

I ran the same identical script with phpinfo() in it from 2 different
locations.

1 I ran from the command line and 1 I ran from the crontab.

The one that i ran from the crontab didn't not have mysql support
enabled.

Looks like that is the problem!

Why are these different?
How do i compile that php version with mysql support?

I believe this should solve this issue.

Thanks!
Which php.ini file is each one using? The version of PHP? Perhaps you
have two copies of php on your system.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: deko | last post by:
Is there a way to get my script to run on regularly scheduled intervals without using cron? My hosting provider sucks... cannot use cron... I was thinking perhaps I could create a file every hour...
5
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
3
by: AR John | last post by:
Hi, Anybody could tell me how a mysql script could be run on mysql on some interval like cron facility in Linux system?. I am using Windows 2K machine. Actually I am developing a PHP...
1
by: Piotr Trawiński | last post by:
I have this notorious problem: at some point pgsql simply hangs up and requires a restart. --------------------------------------------------------------------------- -------...
3
by: the.natalie | last post by:
Hi. I am a newbie to mysql, cron, and shell scripting, so please bear with me. I have a script that is used for updating an image directory based on contents in a database. The script does the...
6
by: BG Mahesh | last post by:
hi I am using PHP 5.0.4 on OpenSuse 10.x. I have the following piece of code, $sp1 = $_SERVER; $sp1 is set correctly when I execute file.php thru the browser. But when I run that script...
2
by: erikcw | last post by:
Hi all, When trying to run this python script from cron, I get the following error: Traceback (most recent call last): File "/home/lybp/public_html/wa/wa.py", line 14, in ? import MySQLdb...
5
by: scriptee | last post by:
Hi , I wan to run a php script using cron on my host server. Its a Linux based server and I am allowed to use cron. I want to run a php script with includes. I tried some suggestions which...
1
by: symbioid | last post by:
Hello, I'm working on a project, and VMware has problems with suspending the virtual machine. We are accessing the machine through samba. However, when I suspend the VM, it stops the Samba...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.