Tom,

Did you run the script from cron?  If so, what operating system are you
using?  Putting PHP info in my script won't do me any good since cron
won't run it.  The trouble is that cron does nothing.  When I run the
email script I get no mail.  If I run the script from the command line
by hand ./script_name etc it works fine.

Any other ideas would be great.

Thanks

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X

Hi,

Monday, March 3, 2003, 6:33:46 AM, you wrote:
JMC> Does anyone have a PHP CLI script running from cron?

JMC> If so I would greatly appreciate any assistance.  Below is
everything
JMC> from this on going problem.  It seems none has an answer so far.

JMC> Please help.
JMC>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

JMC> I tried to run the script directly from cron like:

JMC> * * * * * /usr/local/bin/php -q /path/to/cron/script/file_name

JMC> I also tried to run cron in the bash environment by writing a bash
JMC> script that calls my PHP script.  I set cron you call the bash
script
JMC> every minute. The bash script contained the following information:

JMC> ================================ START SCRIPT
JMC> =============================
JMC> #!/usr/local/bin/bash
JMC> /path/to/PHP/script/file_name
JMC> ================================= END SCRIPT
JMC> ==============================

JMC> If I run the bash script from the command line it definitely runs
my PHP
JMC> script. I know this because my PHP script sends me an email. 

JMC> Also, if I run my PHP script from the command line it also runs
fine and
JMC> I receive an email.  However, anytime I try to run PHP script or
the
JMC> bash script from cron nothing happens.  I get no emails.  I also
know
JMC> cron is working properly because a regular bash script as I listed
in my
JMC> earlier posting works fine.

JMC> This is using the new CLI that come with PHP 4.3 I have in past
versions
JMC> of used the CGI from cron with no problems at all.  As a matter of
fact
JMC> I have another server that does all its maintenance via PHP scripts
that
JMC> get ran by cron

JMC> Here is the PHP CLI cron script I am testing to see if cron will
run my
JMC> PHP

JMC> ================================ START SCRIPT
JMC> =============================
JMC> #!/usr/local/bin/php -q
JMC> <?

JMC> mail("[EMAIL PROTECTED]","Message From cron",date("F j, Y @ h:i
a"));

?>>
JMC> ================================= END SCRIPT
JMC> ==============================
 

JMC> Any more suggestions would be greatly appreciated.

JMC> Justin

JMC> -----Original Message-----
JMC> From: CodersNightMare [mailto:[EMAIL PROTECTED] 
JMC> Sent: Friday, February 28, 2003 10:32 AM
JMC> To: [EMAIL PROTECTED]
JMC> Subject: RE: [PHP] Can't run PHP cli script from Cron


JMC> I am sure you have tried this, but,
JMC> Do you call the full path to php for cron.

JMC> something like:

JMC> 40 * * * * /usr/local/bin/php -q /home/user/phpcliscript

JMC> Hope this helps.


JMC> At 10:10 AM 2/28/2003 -0800, you wrote:
>>The path is
>>
>>#!/usr/local/bin/php -q
>>
>>But like I said, that can't be the problem because when I run it from
>>the command line, it runs fine.  The only problem I am having is that
JMC> it
>>won't run from cron.  That is why I think it is an issue with the cron
>>environment.  All other types of scripts like bash scripts run fine
JMC> from
>>cron.  I am surprised no one else has come across this problem before.
>>
>>Please help me!
>>
>>  Justin Michael Couto                [EMAIL PROTECTED]
>>Director of Operations              805.781.0420
>>Somnio World Web Solutions          http://www.somnioworld.com
>>
>>
>>-----Original Message-----
>>From: R'twick Niceorgaw [mailto:[EMAIL PROTECTED]
>>Sent: Friday, February 28, 2003 9:44 AM
>>Cc: [EMAIL PROTECTED]
>>Subject: Re: [PHP] Can't run PHP cli script from Cron
>>
>>Shouldn't it be
>>#!/usr/local/bin/php
>>
>>Or was it just a typo here?
>>
>>----- Original Message -----
>>From: "Justin Michael Couto" <[EMAIL PROTECTED]>
>>To: "'Ernest E Vogelsinger'" <[EMAIL PROTECTED]>
>>Cc: <[EMAIL PROTECTED]>
>>Sent: Friday, February 28, 2003 12:09 PM
>>Subject: RE: [PHP] Can't run PHP cli script from Cron
>>
>>
>> > I can run it from the shell prompt perfectly fine.  I just won't
run
>> > from cron.
>> >
>> > I do have the statement:
>> >
>> > #!/usr/local/php
>> >
>> > In the beginning of my script.  Like I said it works perfect when I
>>run
>> > it by hand from the shell prompt.  I think the reason it is not
>>running
>> > has to do with the cron environment, but I am not ssure what it is.
>> >
>> > Justin Michael Couto                [EMAIL PROTECTED]
>> > Director of Operations              805.781.0420
>> > Somnio World Web Solutions          http://www.somnioworld.com
>> >
>> >
>> > -----Original Message-----
>> > From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]
>> > Sent: Friday, February 28, 2003 12:55 AM
>> > To: Justin Michael Couto
>> > Cc: [EMAIL PROTECTED]
>> > Subject: Re: [PHP] Can't run PHP cli script from Cron
>> >
>> > At 05:30 28.02.2003, Justin Michael Couto said:
>> > --------------------[snip]--------------------
>> > >Here is my crontab entry:
>> > >
>> > >* * * * * /path/to/file/file_name.php
>> > >
>> > >I also have
>> > >
>> > >* * * * * /path/to/file/bash_test_script
>> > --------------------[snip]--------------------
>> >
>> > Did you try to run the php file interactively, from the shell
JMC> prompt?
>> >
>> > You need at last this statement on top of your PHP files:
>> >     #!/usr/local/php
>> >
>> >
>> > --
>> >    >O     Ernest E. Vogelsinger
>> >    (\)    ICQ #13394035
>> >     ^     http://www.vogelsinger.at/
>> >
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php



JMC> -- 
JMC> PHP General Mailing List (http://www.php.net/)
JMC> To unsubscribe, visit: http://www.php.net/unsub.php


JMC> -- 
JMC> PHP General Mailing List (http://www.php.net/)
JMC> To unsubscribe, visit: http://www.php.net/unsub.php

Put phpinfo(); in your script and you should get an email from cron
with the output of your script. See if there is anything in there that
can give you a clue.
I ran your script using cli 4.3.0 and it worked fine.
What user are you running cron as?

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to