Cron is too slow, logs behave strangely

Nextcloud version (eg, 29.0.4):
Operating system and version _(eg, Ubuntu 24.04)
Apache or nginx version (eg, Apache 2.4.25): replace me
PHP version (eg, 8.3): replace me

The issue you are facing:

Hello
I installed nextcloud a few months ago. Until now I never ran the cron.php file, because I didn’t understand how to automate it.
But now every time I manually run a :
’ sudo docker exec -u www-data nextcloud php /var/www/html/cron.php’
the cron takes 20 minutes to run.
I’ve got a powerful server (5600g with 2 gigs of ram dedicated to nextcloud), and only a dozen users.
Why does it take so long?

Steps to replicate it:

  1. sudo docker exec -u www-data nextcloud php /var/www/html/cron.php
  2. waiting too long

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

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

<?php
$CONFIG = array (
  'default_phone_region' => 'optional',
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'nextcloudfinal-redis-1',
    'password' => '',
    'port' => 6379,
  ),
  'upgrade.disable-web' => true,
  'instanceid' => 'ockqp1x5emn4',
  'passwordsalt' => 'something',
  'secret' => 'something',
  'trusted_domains' => 
  array (
    0 => 'cloud.mysite.org',
  ),
  'trusted_proxies' => 
  array (
    0 => 'mysite-proxy',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '29.0.4.1',
  'overwrite.cli.url' => 'http://cloud.mysite.org',
  'dbname' => 'cloud',
  'dbhost' => 'nextcloud-db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'something',
  'installed' => true,
  'maintenance' => false,
  'loglevel' => 0,
  'mail_from_address' => 'atelier',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'mysite.org',
  'mail_smtphost' => 'othersite.me',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'atelier',
  'mail_smtppassword' => 'something',
  'overwriteprotocol' => 'https',
  'maintenance_window_start' => 4,
  'app_install_overwrite' => 
  array (
    0 => 'spreed',
  ),
);

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.
I don’t understand why, but I can’t download nextcloud.log in its entirety. It’s currently downloading at over a hundred megabytes.

That may be a clue, or it may simply mean you may want to enable log rotation. :slight_smile:

Try just doing a tail on the log file (to see the latest couple entries and new ones in real-time):

 docker compose exec -u33 app tail -f /var/www/html/data/nextcloud.log

Do this while triggering the cron.php run in another window. It may give you some clues about what is going on.

didn’t understand how to automate it.

So are you running cron from your Compose file now or… ?

EDIT: This is probably why you log is so huge:

  'loglevel' => 0,

This should be 2 (the default). The level you have it at right now is debug level, which should never be left running in production. It’ll generate insane amounts of logging and also slow things down.

1 Like

thanks for your help. Indeed that was the problem, now the cron only takes a few seconds.
Should I delete the giga of useless log from nextcloud?
Now I will automate the cron.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.