to run php from the cron directly you need to take care of a couple things.
First, your php needs to be executable, also by the user that is executing it. often this user is NOT the same as the user that is used for uploading it.
Do this by setting the permissions to 550 or 555 using chmod or whatever interface you have to work with (sometimes it can work from the ftp/scp program you use)
second, your php program needs to let the shell know where to find its interpreter.
All executable shellscripts start with something that unix-nerds like me tend to call a shebang. the shebang for a php executable is
CODE
#!/usr/local/bin/php
This needs to be placed _before_ the <?php and other code.
It is very important that you have the path to the php binary correct. the above is on a FreeBSD system, on the system you are being hosted on it might be somewhere else. Look, or ask.
So a typical executable can look something like this:
CODE
#!/usr/local/bin/php
<?php
dostuff();
?>
Please note that very often any output from cronjobs are discarded. Echos etc have no effect.
If you need to do debugging you will have to write the debugstatements to a file.
And then in the cron:
I use the www user (that is owning the webserver processes) to run php cronjobs, so when i edit the crontab i su to root and then use
crontab -e -u www
to edit www's crontab.
in the crontab you can find (for example):
CODE
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
HOME=/var/log
#minute hour mday month wday command
1 0 * * * /www/pjr_cron_scripts/dostuff.php
10 3 * * * /www/pjr_cron_scripts/dootherstuff.php
but i dont know if you can edit the crontab directly or you have to use some tool to do it.
Anyway, if you have all this in the right places, it should run.
Test with a simple script, as script errors will abort the job.
Take note of the paths. These examples are taken from a running FreeBSD server, and might be different on your system.