Running cron from cli in drupal will result in.
PHP Warning: include_once(): Failed opening './includes/bootstrap.inc'
Running cron from cli is useful when your behind external authentication and crontab is not available over http. Because normaly you would put something like:
0 * * * * wget --spider <a href="http://yoursite/cron.php
So here is what you should put in the crontab when you want it to call from cli. (Edit using "crontab -e" as command)
* * * * * php /home/ddcooman/workspace/extranet-client/src/drupal/cron.php
As said this gives the error. So here is the solution:
Create a new cron file "cronlocal.php" containing:
<?php
// $Id: cronlocal.php Exp $
/**
* @file
* Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
*/
$path='/home/ddcooman/workspace/extranet-client/src/drupal';
chdir($path);
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_cron_run();
?>
The chdir will change the directory and bootstrap drupal. After drupal is bootstrapped the drupal cron is executed.
Tip: You can also use this trick to bootstrap drupal for running import scripts. The whole drupal api is available when drupal is bootstrapped.
Links
[1] https://dominiquedecooman.com/blog-topics/php
[2] https://dominiquedecooman.com/blog-topics/linux-0
[3] https://dominiquedecooman.com/blog-topics/cron
[4] https://dominiquedecooman.com/blog-topics/cli