Cron not working (ISPConfig)

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 25.0.2.3
Operating system and version : Ubuntu 22.04
Apache or nginx version: 2.4.52
PHP version: 8.0
Web Hosting Panel: ISPConfig 3.2.9

The issue you are facing:

When setting cron, it is not normally applied. After 10 minutes, the following message is displayed.
‘Last background job execution ran 10 minutes ago. Something seems wrong.’

Is this the first time you’ve seen this error? : N

Here’s how I tried to fix this problem.
https://forum.howtoforge.com/threads/nextcloud-cron-error-ubuntu-22-04.90018/

Modify crontab
crontab -u www-data -e
*/5 * * * * php -f /var/www/clients/client0/web2/web/cron.php
Problem still not resolved.

Add --define apc.enable_cli=1 to cron
crontab -u www-data -e
*/5 * * * * php -f /var/www/clients/client0/web2/web/cron.php --define apc.enable_cli=1
Problem still not resolved.

Add Cron Jobs in ISPConfig
Problem still not resolved.

Modify apcu.ini
Add apc.enable_cli=1 to /etc/php/8.0/mods-available/apuc.ini
Problem still not resolved.

Replacing memory caching from APCu to Redis
Problem still not resolved.

'filelocking.enabled' => true,
  'memcache.local' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => ****,
    'password' => '****',
  ),

The output of your config.php file in '/var/www/clients/client0/web2/web/config/config.php:

<?php
$CONFIG = array (
  'filelocking.enabled' => true,
  'memcache.local' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => ****,
    'password' => '****',
  ),
  'default_phone_region' => 'KR',
  'instanceid' => '****',
  'passwordsalt' => '****',
  'secret' => '****',
  'trusted_domains' => 
  array (
    0 => '******.com',
  ),
  'datadirectory' => '/var/www/clients/client0/web2/web/data',
  'dbtype' => 'mysql',
  'version' => '25.0.2.3',
  'overwrite.cli.url' => 'https://*****.com',
  'dbname' => '****',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '****',
  'dbpassword' => '****',
  'installed' => true,
  'mail_smtpmode' => '',
  'mail_sendmailmode' => '',
  'mail_domain' => '',
  'mail_smtpsecure' => '',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'mail_smtpauthtype' => 'LOGIN',
);

I’ve tried most of the possible solutions, but the problem hasn’t been resolved.
Is this a problem because the website owner and group are not www-data:www-data?

Definately the reason, yes.

1 Like

@Kerasit Not necessarily. If the web server is managed by ISPconfig, it is quite possible that it runs under a different user.

@i7-13700K I don’t know ISP config, but I would also ask here… https://forum.howtoforge.com/

Side note: I could be missing something, but there appears to be no specific tutorial on www.howtoforge.com, on how to run Nextcloud together with ISPconfig. All the Nextcloud tutorials on their site, seem to be about installing Nextcloud directly on various Linux distributions, and none of them is even mentioning ISPconfig. Not sure what to make of that :thinking:

1 Like

True. But that would give other issues with Nextcloud if the owner as listed in the screenshot, is not the same as the user running the webserver process. So I automatically assumed that it was one and the same, hence that would make sense why cron not working. However here he has access to run sudo -u www-data in a cli hence I also assumed that it was not a shared web server resource, rather than a VM or LXC.

1 Like

Can you run this command

top
1 Like

Looking at your ISPConfig cron setup screenshot (the ISPConfig portal), you are pointing to a php file, but is not asking it to run with PHP engine. I would assume you needs to do this excactly like you did the crontab:

php -f /var/www/clients/client0/web2/web/cron.php

You might have to define full path to PHP executeable aswell. Is PHP-CLI even installed?

To try and do this using as native ISPConfig as possible, then use the webcron feature. It does say:
Command to run (commands are executed via sh, urls via wget).

1 Like

Yes. Execution is possible.

Even if I add php -f to ISPConfig, the problem is still there.
Exceeded 5 minutes.
https://drive.google.com/file/d/14giZPbvsWP0oQV4gegug6M2epoCAnR1Q/view?usp=share_link
https://drive.google.com/file/d/1fxZhPDpZT5t9NWtI8mDzt7H1WAnKfw5Y/view?usp=share_link
php-cli is installed.

@Kerasit egistering cron.php in web2 also runs the problem.

how did you write the webcron path?

1 Like

5 minutes execution time is not unheard of when talking CRON.
Needs to tweak the php-cli .ini file to accomodate for heavy load. Cron is doing alot of backrground stuff.

1 Like

No. Do not use ISPConfig defined path. It is an example. the cron.php file for nextcloud, is under the nextcloud folder structure.

1 Like

php-cli -f /var/www/clients/client0/web2/web/cron.php
https://my*domain.com
I solved it by adding the above.
System cron now works normally.

2 Likes