Re: PHP CLI Problem

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

 




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


[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