Forum Moderators: bakedjake
The line looks something like this:
0 0 * * * /path_to_php/php -q /path_to_script/script.php arg1 arg2
The script is being called fine, but the php doesn't seem to be being passed the arguments.
I've tried putting quotes around various parts of the script call, but no luck.
Can anybody shed any light on this one?
It seems as though the php script is receiving the arguments. However, when the script tries to connect to a mysql database, it is rejected.
When called via a browser, it is accepted. This seems to indicate a user permission error... I assume the cron jobs are running under a different user than the browser php calls...
The PHP scripts when run through a browser (from the web server) run with very few permissions.
CRON however, is run at root level (most often) and so runs with loads more permissions.
As for the fact that it doesn't connect to the database..I don't really know.
But, just out of interest, when you are connecting to the MySQL server, are you connecting to it as:
'localhost'
'IP Address' or 'hostname'?
Wonder whether this would make any difference?
HTH,
William.
[edit]Typo corrected[/edit]
That will depend on your MySQL [mysql.com] permissions [mysql.com].
Andreas
Is there anyway to find out what user my cron job is running under? Basically I think that it must be the user that I'm logged in as via SSH. However, I set up permissions on mySQl for that user, and still no success.
I figure that if I can work out through mySQL which user is getting rejected, then I can add that user...
Does that make sense?
Andreas
I know it doesn't really help, but if you could make your PHP page into PERL, it can be run from CRONTAB/ROOT very easily, and securely.
I have many perl scripts running on cron, including stats and backup scripts.