I've just done my first cron job. But I'm getting error messages from crontab that I don't understand.
The script that is to run is supposed to delete all the files in a temp folder on a daily basis. Here is the script,
[pre]
<?php
$dir_path="./temp/";
if ($handle = opendir($dir_path))
{
/ This is the correct way to loop over the directory. /
while (false !== ($file = readdir($handle)))
{
if($file == '.' || $file == '..')
continue;
$file = $dir_path.$file;
unlink($file);
}
closedir($handle);
}
?>
[/pre]
I've set up the cron job using Cpanel at my website. It gets run but each time I get
these error messages,
/home/fermat/public_html/clear_files.php: ?php
: No such file or directory
/home/fermat/public_html/clear_files.php:
: command not found
/home/fermat/public_html/clear_files.php: =./temp/: No such file or directory
/home/fermat/public_html/clear_files.php:
: command not found
/home/fermat/public_html/clear_files.php:
: command not found
/home/fermat/public_html/clear_files.php: line 5: syntax error near unexpected token
opendir($'
/home/fermat/public_html/clear_files.php: line 5: if ($handle =
opendir($dir_path))
'
I can understand the "=./temp/: No such file or directory" error, with those after just looking like follow-on errors. But can someone explain what the first error message means, and why I get it?