Backgroud jobs with cron

Hello,
For a few days, I have been getting an error message regarding backgroud jobs (in french, sorry…):

 Quelque chose s'est mal passé lors de l'exécution de la dernière tâche il y a 28 minutes.

Until now, I was using cron as described here and everything worked fine. This message appeared (maybe since the last update to version 21.0.3 ??). I tried to switch to a systemd service as described here, but no more results; still the same error message.
However, it seems that the task is performed every 5 minutes:

● nextcloudcron.service - Nextcloud cron.php job
   Loaded: loaded (/etc/systemd/system/nextcloudcron.service; static; vendor pr
   Active: inactive (dead) since Wed 2021-07-14 12:31:47 CEST; 1min 3s ago
  Process: 12368 ExecStart=/usr/bin/php -f /var/www/html/nextcloud/cron.php (co
 Main PID: 12368 (code=exited, status=0/SUCCESS)

Jul 14 12:31:46 odroidn2 systemd[1]: Started Nextcloud cron.php job.
Jul. 14 12:31:47 odroidn2 systemd[1]: nextcloudcron.service: Succeeded.

● nextcloudcron.service - Nextcloud cron.php job
   Loaded: loaded (/etc/systemd/system/nextcloudcron.service; static; vendor pr
   Active: inactive (dead) since Wed 2021-07-14 12:36:48 CEST; 16s ago
  Process: 12563 ExecStart=/usr/bin/php -f /var/www/html/nextcloud/cron.php (co
 Main PID: 12563 (code=exited, status=0/SUCCESS)

Jul. 14 12:36:47 odroidn2 systemd[1]: Started Nextcloud cron.php job.
Jul. 14 12:36:48 odroidn2 systemd[1]: nextcloudcron.service: Succeeded.

Any help?

Under which environment you’re running Nextcloud, a dedicated server, docker, etc.?

Unfortunately I cannot see under which user you’re executing the cron.php script. By default it should be executed every 5min by your web server user, e.g. “www-data” or “wwwrun”, etc.

Have you tried to execute the command manually on the console to see if any error messages are being displayed?

Thanks for the reply.

A dedicated server with debian (armbian), php 7.3, apache 2.4.38-3+deb10u5.

how to check this ?
The user is correctly specified in the conf file :

# cat /etc/systemd/system/nextcloudcron.service 
[Unit]
Description=Nextcloud cron.php job

[Service]
User=www-data
ExecStart=/usr/bin/php -f /var/www/html/nextcloud/cron.php
KillMode=process
root@odroidn2:~# /usr/sbin/runuser -u www-data -- /usr/bin/php -f /var/www/html/nextcloud/cron.php
root@odroidn2:~# 

No errors

That’s indeed strange. It seems that the cron job is being executed correctly. Are there any related error messages in the Nextcloud log file?

No

I am obviously not alone… :
https://help.nextcloud.com/t/cant-run-background-jobs-with-system-cron/118745/2

I’m personally not using systemd but the normal crond to schedule tasks. Therefore you should check if these tipps are helping you to set-up systemd.

I, too, am having this issue with cron. Switching settings in NC does nothing. Setting up as cron does nothing and running as systemd does not fix this. Appears to be related to latest version.

Letzte Cron-Job-Ausführung: Vor 12 Tagen. Möglicherweise liegt ein Fehler vor. [Überprüfe Einstellungen für Hintergrundausführungen]
Gleicher Fehler, gleiche Version
Debian 10
lxc

Does the occ CLI tool work for you? I noticed that occ throws an error about an unconfigured APC module, and i had to set apc.enable_cli=1 in my PHP configuration. After i did, cron jobs worked again.

1 Like

Danke. Funktioniert.
/etc/php/7.4/mods-available/apcu.ini
apc.enable_cli=1

1 Like