Picky CRON


#1

New to Cron…got the file setup and working, and it emails me when the job doesn’t execute correctly.

I am having it execute a PHP file and the email details of the problem are:

xxxxx/makerss.php: line 1: ?php: No such file or directory
xxxxx/makerss.php: line 2: //: is a directory
xxxxx/makerss.php: line 3: syntax error near unexpected token (' xxxxx/makerss.php: line 3: $fp = fopen (“rss.xml”, “w”);’

and here is the beginning of the PHP file:

<?php // open a file pointer to an RSS file $fp = fopen ("rss.xml", "w"); // Now write the header information fwrite ($fp, "<?xml version='1.0' ?>");

What’s going on? If I run the file makerss.php from a browser it executes fine.

Thanks


#2

You need to tell cron to execute your php file with php. Either change your crontab to run:

/usr/local/bin/php -q xxxxx/makerss.php

or put the following line at the top of your php file:

#!/usr/local/bin/php -q

/usr/local/bin/php is php 4. If you want php 5 use /usr/local/php5/bin/php instead.