Re: PHP CLI Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 6, 2008 9:36 AM, Robbert van Andel <robbert@xxxxxxxxx> wrote:

> I guess I spoke too soon.  Even though the script runs from anywhere (that
> I
> have access too), when I put the perl script in a cronjob, the php script
> just refuses to run.  There's no output, just the output from the perl
> script.  And yes, I did set up the perl script to print the output of the
> php script.  Any ideas?  Is there some special consideration I have to
> give
> to the fact that my PHP installation is setup as a CGI?  I've never had
> this
> much trouble getting a PHP CLI script to run.


there are 2 ways to run a php cli script.  the first is to prefix the name
of the script
with php; eg
php backup.php

if you are specifying this in a cron job, you will have to supply the full
path to the php
interpreter, which you can find via
which php
(sorry jocheem, i know you already said that, but my system doesnt have
php5, only
php [even though its 5] so i thought id mention it again)

that is the way i prefer to do it but i wont elaborate as there is no point
now.
the second way is to make the script executable; this is a 2 step process.
the first step
is to prefix the contents of the file with
#!/path/to/php/binary
where the path is the same as earlier, found via the which command.  the
second step is
to mark the script as executable, hopefully you are familiar enough to do
that yourself,
but just to test it as the user who created it, you can do simply,
chmod u+x backup.php

i suspect in your case the cron job doesnt know the path to the php binary,
ive encountered
this before; although its strange its still occurring within the perl
script; however i cant help you
with that ;)

o, btw; here is the relevant page in the manual
http://us2.php.net/manual/en/features.commandline.php

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux