A webcron issue - executed irregularly

Nextcloud version: 29.0.6
Operating system and version: Linux 5.4.0-195-generic x86_64
Apache or nginx version: Apache
PHP version: 8.1

The issue you are facing:
I am using webcron for e-mail notifications for file operation, uploads etc.
The notifications should be sent hourly, but in fact it often takes many hours.
cron.php runs reliably every 5 minutes.

In the log file I found this entry for any time at which cron.php is running:

[PHP] Error: opendir(/tmp): Failed to open directory: Permission denied at /www/htdocs/xxxxxxx/nextcloud/lib/private/TempManager.php#191
	GET /cron.php

In the PHP file line 191 is

		$dh = opendir($this->tmpBaseDir);

It’s inside a protected function:

protected function getOldFiles() {

Maybe that’s a dead end, but is there perhaps a correlation to my problem?

Thanks in advance

Webcron has limitations and Nextcloud has many background jobs that need to run. Webcron, however, only runs one job per trigger so it’s severely limited.

Is there a reason you are unable to use the OS’s cron?

Error: opendir(/tmp): Failed to open directory: Permission denied at /www/htdocs/xxxxxxx/nextcloud/lib/private/TempManager.php#191

Having an inoperative temp directory will cause all sorts of issues.

Set the tempdirectory parameter to specify a custom temporary directory so that your instance has something your instance it can use if /tmp isn’t an option.

1 Like

I had read about these limitations, but that was new to me:

because of shared hosting. I can use SSH and tried to install a crontab, but of course I had no permissions.

For me it’s not possible, I have tried to create a temp directory with different names and file permissions and wrote it in the config.php:

Temporary directory /xxxx is not present or writable

Also with crontab -e?

1 Like

Yes, I created the crontab with the command from the nextcloud docs.
First to the directory, where Nextcloud ist installed and then

nano crontab -u www-data -e

and then:

*/5 * * * * www-data php -f /www/htdocs/xxxxxxxx/nextcloud/cron.php

And when I take a look in the database nothing happend, the timestamp is hours ago:

Sorry,
hallelujah, now the cronjob is running!
I was not patient enough.

Thank you both for your helpful hints!

Hi,
since the update to NC30 on 2 instances I get the warning, that Cron wasnt executed since 5 days.

I changed nothing regarding the setup/ config

Cron via Crontab

I

@Dayspring What is your nextcloud.log saying? Search for Error while running background job Messages. Maybe you have the following problem:

Hi @mritzmann , thank you, but there is no such message in the now over 500MB logfile, started on 15.09.2024.

There is not one entry regarding cron or background. I just deleted the logfile, startet the cronjob and there were just a few entries regarding kee alive and passwords

Same Problem, now its

Some jobs have not been executed since vor 12 Tagen. Please consider increasing the execution frequency.

First of all, you don’t need to prepend nano to the crontab command, because it’ll automatically open your system’s default editor, so just use the following command instead:

crontab -u www-data -e

Secondly, you should remove www-data from the line in your crontab, as it is not needed, since with the above command you have already created a crontab specifically for the user www-data, which means the commands in it will always run as www-data anyway. And more importantly, if you put www-data in there like you did, it will be interpreted as a command, which cannot work. So the line in the crontab should look as follows…

*/5 * * * * php -f /www/htdocs/xxxxxxxx/nextcloud/cron.php
1 Like

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