I'm trying to run cron.php via a cron job set up in crontab on my server via the following command (running every 2 minutes purely for testing while I try and get it working - it will be every 6 hours when fixed);
*/2 * * * * /usr/bin/php -q /var/www/www.mysite.com/crontab-cron.php >>/var/log/server-cron.log 2>&1
The crontab file was needed to work around an error with the include file locations and looks like this;
<?php
$doc_root = dirname($_SERVER["SCRIPT_FILENAME"]);
chdir($doc_root);
include_once './cron.php';
?>
However now I'm receiving the error (shown in the cron log file)
PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) in lock_may_be_available() (line 167 of /var/www/www.mysite.com/includes/lock.inc).
I've come across a few suggestions mentioning creating a new database user with the same permissions and changing those details in settings.php
but that's not making any difference.
Any ideas how to get this working? I just need to run the cron job via crontab.
curl --silent --compressed http://example.com/cron.php?cron_key=<key>
and obtain the same. – kiamlaluno♦ Jul 11 '15 at 15:37wget
withcurl
. Fundamentally, your solution is the same. – Blake Frederick May 15 '17 at 15:10