Click to See Complete Forum and Search --> : PHP and cron jobs


SasonX
08-27-2002, 10:40 PM
Hi,

I wanted to set up a cron job to extract data from a MySQL database, formatting the results. My Linux system does have a /usr/bin/php and I tried /usr/bin/php < test.php (it simply had phpinfo() in it ) and that worked fine, but when I tried anything against the MySQL database it complained of not finding the mysql_pconnect function.

Does anybody know how I can do do this .. do I need to recompile PHP or something like that, or change my PATH etc .. or can I NOT use PHP for such tasks ( advise on other possibilities would be helpful if I cant do this in PHP)

Thanks in advance

frigidman
08-28-2002, 12:44 PM
I had that problem at first on my Yellowdog linux box. The commandline version of the PHP it installed, didnt have --with-mysql set. You are most likely going to have to recompile PHP for commandline use and inclue the mysql libraries/headers.

To do this, find out the entire configure string for your web based PHP (use the phpinfo() function in a web page to find it at the top). Copy that, then edit out "--with-apxs" (if that is how it was configured, usually the case though, as the alternative would be something else) and ADD "--without-apache --enable-force-cgi-redirect".

Then recompile and install. It should NOT alter your php.in... should NOT alter you php for your webserver either... BUT, just to be on the safe side, I would suggest you make copies of those two files before you do this, just in case.

This is normally where those things are installed by default with redhat flavour os distributions (you may find yours in different places):

cp /etc/php.ini /etc/php.ini~
cp /usr/lib/apache/libphp4.so /usr/lib/apache/libphp4.so~

Anyhow, this is how I got my command line php installed to act exactly like my web version, so i had no guesswork to do with crontab php scripts (and shell php scripts). Hope this helps... if you are using mandrake, or some other OS... your milage may vary.

deharsh
09-03-2002, 05:50 AM
i never get shell php working in my systems.
i use the following combinations to get the cron job done:
1) the crontab
2) the wget utility

just fetch wget http://127.0.0.1/what_ever.php will do

hope it helps.

deharsh