Drupal 8 cron not running from external source (as anonymous) Running cron with crontab is not working on our Drupal 8 website if the user is anonymous. If I'm logged in as admin, I can run cron with the button or the url with key. If I'm not logged in, cron doesn't run with url with key.

Running from crontab is of course anonymous and so cron is not running.

Any ideas?

Version: Drupal 8 beta 4

Line in crontab: 

*/5 * * * * wget -O - -q -t 1 http://www.entityone.be/nl/cron/theactualcronkeyhere
I know the question is old, but I faced a similar problem and would like to help people coming from google.

I assume you have a function in one of your specific cron hooks which needs extra permissions to run which won't work because Drupal runs cron as an anonymous user.

What helps is to identify which hook_cron needs elevated rights and switch to e.g. the admin account before the affected code runs:

use Drupal\Core\Session\UserSession;

// call the account switcher service
$accountSwitcher = \Drupal::service('account_switcher');
// switch to the admin user
$accountSwitcher-&gt;switchTo(new UserSession(['uid' =&gt; 1]));

// run your code here

// switch back to old session
$accountSwitcher-&gt;switchBack();