The "problem" is typically PHP is intended to run as module in a webserver. You may need to install the commandline version of php before you can run php scripts from the commandline:
apt-get install php5-cli
/usr/bin/php
is default location for the php binary to be placed, but if you for instance compile php from source it may be somewhere else.
Typically PHP scripts aren't formatted as shell scripts, so you need to tell cron which interpreter should be used to execute the php script; that's the reason to use the commandline /usr/bin/php /var/www/pgrouting/workshop/web/php/calculation.php
.
You could format you script with the shebang and make it executable (chmod +x script.php
) and then you can call it directly from the commandline, without specifying php as the interpreter ( i.e. ./script.php
) :
#!/usr/bin/php
<?php
print "Hello world!\n" ;
?>
type -a php
. What Linux distro are you on? – slm Nov 14 at 7:19sudo apt-get install php
– slm Nov 14 at 7:36type -a php
, thetype
is a command, he did not mean to type-a php
. You need the PHP interpreter (calledphp
and usually found at/usr/bin/php
) to tun PHP programs. If you don't have one, you can't run them,cron
has nothing to do with it. – terdon Nov 14 at 13:11