Cron job doesn't seem to be run

Nextcloud version (eg, 18.0.2): 18.0.4 (stable at this moment)
Operating system and version (eg, Ubuntu 20.04): Debian Stretch 9.12
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.25 (Debian)
PHP version (eg, 7.1): PHP 7.4.6

The issue you are facing:
I set up cron following the docs (and others cron doc/tuto I found) but it seems it’s not even called once
I did crontab -u www-data -e and add the cron
now I have this (crontab -u www-data -l):

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
MAILTO=mymail

*/5  *  *  *  * www-data /usr/bin/php7.4 -f /var/www/html/nextcloud/cron.php >> /var/log/cron.log

If I understood what i read, it should run the cron.php with www-data user.
but the log file I added isn’t even created.

I laso tried the following crontab line

*/5  *  *  *  * php -f /var/www/html/nextcloud/cron.php >> /var/log/cron.log

but no result either

For now I came back to ajax, but I’d like to set up the Cron to not load it every page load.

Steps to replicate it:

  1. set up cron following the docs (see the crontab above)
  2. wait for the cron
  3. wait again…

The output of your Nextcloud log in Admin > Logging:
not relevant, I didn’t have an error for the last hour I try to set up the cron.
I had error on Groupfolders rights, but as said, not relevant with the cron not running.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):


<?php
$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => '***',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'overwrite.cli.url' => 'https://***/nextcloud',
  'dbtype' => 'mysql',
  'version' => '18.0.4.2',
  'dbname' => 'nextcloud',
  'dbhost' => '127.0.0.1:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_***',
  'dbpassword' => '***',
  'installed' => true,
  'htaccess.RewriteBase' => '/nextcloud',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.release.channel' => 'stable',
  'mysql.utf8mb4' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '***',
  'mail_domain' => 'gmail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => '***@gmail.com',
  'mail_smtppassword' => '***',
  'skeletondirectory' => '',

  'filelocking.enabled' => true,
);

The output of your Apache/nginx/system log in /var/log/apache2/error.log:

[Sun May 24 00:47:04.993738 2020] [authz_core:debug] [pid 16651] mod_authz_core.c(809): [client ***] AH01626: authorization result of <RequireAny>: granted

I only have the above error
i have that from the begining and never took the time to take a look at this one.

I know the cron problem came a lot but none of the thread I read helped me.
I really don’t see where my problem is.
My nextcloud folder is owned by www-data:www-data
my crontab is set for www-data and target the cron.php file.

try this : (as described in nextcloud docs)
*/5 * * * * php -f /var/www/nextcloud/cron.php
you will have to adapt to your nextcloud folder path

and remove the line mailto:mymail

Have you checked the admin panel? There’s an information about the last cron execution on the site on which you can switch the cron types.

Afaik cron.php itself does not not ouput anything, thats why the log js not created at all:

another idea: have you tried to execute the command manually once to see if everything is set up properly php-wise?

sudo -u www-data php -f /var/www/html/nextcloud/cron.php

(or wherever NC is installed) and check if that runs through properly. This would at least eliminate the possibility that things go wrong on the PHP-side of things.