Still no luck running a PHPCLI script from CRON -- getting closer
| From: | Justin Michael Couto | Date: | Tue, 04 Mar 2003 04:58:50 +0000 |
| Subject: | Still no luck running a PHPCLI script from CRON -- getting closer | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138028@lists.php.net to get a copy of this message | ||
I have my PHP script running from cron now as root, but when I try to
run it as a non root user it doesn't work. When I drop down to the non
root user and run the script by hand I get this.
/usr/libexec/ld-elf.so.1: Shared object "libmysqlclient.so.12" not found
any ideas why this wouldn't not happen as root but does as a non root
user?
thanks
Justin Michael Couto justin@somnioworld.com
Director of Operations 805.781.0420
Somnio World Web Solutions http://www.somnioworld.com
-----Original Message-----
From: Tom Rogers [mailto:trogers@kwikin.com]
Sent: Monday, March 03, 2003 6:23 PM
To: Justin Michael Couto
Cc: dhardiker@staff.firstcreative.net; php-general@lists.php.net
Subject: Re[2]: [PHP] Still no luck running a PHPCLI script from CRON
Hi,
Tuesday, March 4, 2003, 10:01:25 AM, you wrote:
JMC> Dan,
JMC> I used your example exactly like you have it specified. My cron
log
JMC> looks like this:
JMC> Mar 3 15:53:00 prod /usr/sbin/cron[3085]: (root) CMD
JMC> (/usr/local/contab-scripts/wibble.php)
JMC> Mar 3 15:54:00 prod /usr/sbin/cron[3085]: (root) CMD
JMC> (/usr/local/contab-scripts/wibble.php)
JMC> However, it does nothing at all. It doesn't create the
JMC> /tmp/wibble.output file. After testing this, I went in and ran the
JMC> wibble.php script by hand from the command line and it worked just
as my
JMC> scripts work when I run them by hand. I ran the cron as root and
ran
JMC> the script by hand as root. I really think there is a bug
somewhere,
JMC> either in FreeBSD or in PHP. I am not sure what it can be. All I
know
JMC> is that other scripts like bash scripts run fine from cron. This
JMC> problem is really weird and I would truly appreciate any more
assistance
JMC> in getting it resolved.
JMC> Thanks everyone,
JMC>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>> Ok, by looking at my cron logs it looks like cron is trying to run my
>> PHP CLI script. However, it is not running it. I only have one line
JMC> of
>> code that isn't commented out and the line simply sends me an email
>> using the PHP mail() function.
JMC> One thing to keep in mind when working with crontab is
environmental
JMC> variables. As in, Cron has none. You have to set any you want in
your
JMC> crontab, or your called scripts. For example, use full paths.
JMC> You shouldnt have to call a shell before calling the php cli. Here
is an
JMC> example script for you to test. My php binary is in
/usr/local/bin/php,
JMC> my
JMC> script is /usr/local/crontab-scripts/wibble.php and the file I am
JMC> writing
JMC> to is in /tmp/wibble.output
JMC> This is what wibble looks like [chmoded to 755, owned by the user
of the
JMC> crontab]:
JMC> #!/usr/local/bin/php -q
JMC> <?php
JMC> if ($fp = fopen("/tmp/wibble.output",a)) {
JMC> fputs($fp, "Script Executed on ".date("YmdHis")."\n");
JMC> fclose($fp);
JMC> } else {
JMC> die("Could not open 'wibble.output' for read / write
operations");
JMC> }
?>>
JMC> and the crontab line I have is:
JMC> * * * * /usr/local/contab-scripts/wibble.php
JMC> and you can see the output of it running every minute:
JMC> tail -f /tmp/wibble.output
JMC> Works fine for me ... try it
JMC> --
JMC> Dan Hardiker [dhardiker@staff.firstcreative.net]
JMC> ADAM Software & Systems Engineer
JMC> First Creative
JMC> --
JMC> PHP General Mailing List (http://www.php.net/)
JMC> To unsubscribe, visit: http://www.php.net/unsub.php
Try removing the -q's and see if root or whatever user cron runs as gets
an email with an error message in it, as cron is actully having a
crack at running the script.
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php