How can I run cron.php via crontab? 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 &gt;&gt;/var/log/server-cron.log 2&gt;&amp;1


The crontab file was needed to work around an error with the include file locations and looks like this;

&lt;?php
$doc_root = dirname($_SERVER["SCRIPT_FILENAME"]);
chdir($doc_root);


include_once './cron.php';
?&gt;


However now I'm receiving the error (shown in the cron log file)

PDOException: SQLSTATE[28000] [1045] Access denied for user &amp;#039;root&amp;#039;@&amp;#039;localhost&amp;#039; (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.
You could run the cron URL that Drupal provides in Administration > Configuration > System > Cron. 

And in your crontab, instead of invoking the cron.php file individually (won't work), you just have to invoke a URL. This can be done with wget, lynx, curl, etc. E.g.:

With wget:                             

0 * * * * wget -O - -q -t 1 http://www.example.com/cron.php?cron_key=&lt;key&gt;


Configuring cron jobs using the cron command