RE: PHP CLI Problem

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

 



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.

Robbert

-----Original Message-----
From: Robbert van Andel [mailto:robbert@xxxxxxxxx] 
Sent: Wednesday, February 06, 2008 6:14 AM
To: php-general@xxxxxxxxxxxxx
Subject: RE:  PHP CLI Problem

Thank you, that was very helpful.  I created a perl script because the shell
script wouldn't run either.  It too gave an error stating the file or
directory could not be found.  The perl script runs a shell command from
within it to run backup.php.  Manual tests show that that works, I put it in
a cron job and am confident that it will run. 

Robbert

-----Original Message-----
From: Chris [mailto:dmagick@xxxxxxxxx] 
Sent: Tuesday, February 05, 2008 11:06 PM
To: Robbert van Andel
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  PHP CLI Problem


> First off, the script runs great from the command line when I type "php5
> backup.php" but when I type ./backup.php I get an error: "bash:
> ./backup.php: No such file or directory".

Maybe backup.php that you think it's running is the wrong one.

Add something like:

echo "I am file " . __FILE__ . "\n";

in your backup.php file and see if that's printed out when you run "php5 
backup.php".

If it's not, then you're editing the wrong file.

>  I thought maybe this is a problem
> with the top declaration in the script "#!/usr/local/bin/php5".

If you have that as the first line, then you should just need to chmod 
+x the backup.php file.

> The problem
> is that it appears the server has several php5s I can reference
> 
> /usr/local/apache/share/cgi-bin/php5
> /usr/local/bin/php5

Ask your host which is the right one (99% sure it'll be 
/usr/local/bin/php5).

> Questions:
> * How do I determine what to put at the top of the script so that I can
just
> call "backup.php"?

What difference does it make whether the full path is included in the 
cron job or not? You need to use the full path somewhere (whether it's 
in the cron job or in a shell script).

You could create a shell script:

#!/bin/bash
/usr/local/bin/php5 -f /path/to/backup.php

chmod +x the new script.

Call that instead in cron.

> * What, if anything, do I need to do to make the script work from cron?

Use the full path to php, use the full path to your backup.php file.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
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


[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