Hi David,
What you need to do is to compile PHP as cgi standalone interpreter and just like perl you need to place the path (#!/usr/local/php-cgi/bin/php -q) of the cgi on the top of the php file. By default, PHP is compiles as cgi interpreter.
Step for compiling PHP as cgi
1 ./configure --prefix=/usr/local/php-cgi
2 make
3 make install
Creat a file name it test.php with the following lines.
#!/usr/local/php-cgi/bin/php -q
<?php
echo "Hello, World!"
?>
You need to enable the execution permission before you run it. If you are the owner of the file, you can run the following command:
chmod 744 test.php
./test.php
It should return "Hello, World!" on your screen.
To schedule it as cron job:
- create a file name it schedule_task and add the following line in
30 17 * /usr/local/php-cgi/bin/test.php
It will be run at 5:30 pm everyday.
To schedule a task run the following command
- crontab schedule_task
To view the its schedule
- crontab -l
To edit it
- crontab -e
Here is an article that you can learn PHP in shell script.
http://www.phpbuilder.com/columns/darrell20000319.php3
Have Fun with PHP (:
Bn