cron job nightly error log


#1

I have a *.php file that runs on a cron schedule. I have this script

[php]
$db = mysql_connect(“localhost”, “user”, “pass”);
mysql_select_db(“dbname”, $db);
$result = mysql_query(“SELECT * from active”) or die(mysql_error());
$result2 = mysql_query(“SELECT * from archives”) or die(mysql_error());
[/php]

When I run the script I do not get the same errors. These errors only show in the error log of the cron job.

The error is…

/home/user/public_html/wolfpack/script/MO_reader.php: ?php: No such file or directory
/home/user/public_html/wolfpack/script/MO_reader.php: line 2: syntax error near unexpected token mysql_connect("' /home/user/public_html/wolfpack/script/MO_reader.php: line 2: $db = mysql_connect(“localhost”, “user”, “pass”);’

Thank you for your help. It is of much help.


#2

Don’t know much but… Does it have the proper permissions? I think the PHP has to be configured to work on the command line also?


#3

What permissions does a cron job have? Is it in my same group or what? How do I know what to give it, without giving it 777?

Thanks again


#4

have you manually tried to run this job from the command line (without the browser) ? Does it work or do you get an error? It seems like it’s trying to read the file like a script but doesn’t understand what to do with it, which leads me to think that you are not configured to run php at command line.

Also what does your cron job entry look like? Can you post it here.

As far as permissions go, it needs the appropriate permissions to access the needed files (PHP Binary and the script itself). Whatever user the Crontab is running as should have read/execute on the the script and the binary.