AJAX, Cron and running background job on shared webhosting

Hi everyone,

Nextcloud version: 21.0.3
Operating system and version: Linux (on Webhosting manitu.de)
PHP version (eg, 5.6):7.4
Is this the first time you’ve seen this error?:no
Can you reliably replicate it? Yes
The output of your Nextcloud log in Admin > Logging:

Error PHP Error: is_file(): open_basedir restriction in effect. File(/l10n/en.js) is not within the allowed path(s): (/home/sites/site100024487/:/home/sites/www.MYSITE.de/:/tmp/:/dev/:/usr/share/php/:/etc/ssl/certs/:/usr/lib64/php7.3/bin/:/usr/lib64/php7.4/bin/:/usr/lib64/php8.0/bin/) at /home/sites/site100024487/web/MYSITE.de/lib/private/Template/ResourceLocator.php#106 seconds ago
Error PHP Error: file_exists(): open_basedir restriction in effect. File(/templates/) is not within the allowed path(s): (/home/sites/site100024487/:/home/sites/www.MYSITE.de/:/tmp/:/dev/:/usr/share/php/:/etc/ssl/certs/:/usr/lib64/php7.3/bin/:/usr/lib64/php7.4/bin/:/usr/lib64/php8.0/bin/) at /home/sites/site100024487/web/MYSITE.de/lib/private/Template/Base.php#68

Apache and linux on shared webhosting.

Hi everyone,

I run NC 21.0.3 on a shared webhosting (www.manitu.de)

Concerning the « Background jobs » settings of NC :

we have the choice between AJAX, Webcron and Cron, and « For bigger instances ‘Cron’ is the recommended setting.»

My first question is : when is my NC instance a bigger instance ? Is that about the number of NC users ? About the size of data stored in the cloud ?

My second question is : when I switch from AJAX to Cron, then I get the warning (under « Settings », « Basic settings ») that « Some jobs didn’t execute since 5 days ago. Please consider switching to system cron. »

Also, the page « Settings », « Basic settings » suggests that (when using Cron), I should « Use system cron service to call the cron.php file every 5 minutes. »

However, my shared webhosting offers the possibility to run cron jobs only every hour.

Is that really a problem in case I select Cron for running the background jobs ??

Third question : how can i know which jobs and when jobs have not been executed ?

Thank you for your help !

Best,

Vincent

Read this.

Yes. But mostly you can not use it on shared webhosting

Yes. There is no cron job. There is no cron job for nextcloud.

Yes? Then you must configure the cron job.
Read part “cron” in documentation.

For cron there are e.g. server logs and you can move output to a file.
Read this.

Thank you devnull for your reply and for trying to help.

Nextcloud recommends running the cron job every 5 minutes.

However, my webhosting offers the possibility to run a cron job only every hour.

What should I do (and why) ?! Keep running AJAX or go for cron with a longer time interval between jobs execution ???

Best,

V

Hi @vmunich77

Both is at least suboptimal imho. But it depends on how you plan to use your Nextcloud. If you just use it to store your personal files you probably won’t have any issues with either one. If you want to use the full functionality with multiple users, file sharing, calendars, notifications, Nextcloud Talk, Collabora etc… you probably shouldn’t use a shared webhosting anyways and use a VPS instead…

If you don’t want to manage a full blown LAMP/LEMP stack with a manual installation of Nextcloud yourself, you could use the Snap package or something like NCP on that VPS…

Hi @vmunich77 and @bb77

or you use a “Managed Nextcloud” from a Nextcloud Hoster who has optimized all Nextcloud functions. You get get 1 to 8 GB for free. Mostly data on Managed Nextcloud (e.g. 500 GB) is cheaper than webspace. Also you must not upgrade you nextcloud.

You can test a demo nextcloud from Nextcloud GmbH.

Link: https://try.nextcloud.com
Username is generated
Password is: demo
Nextcloud server is https://demo1.nextcloud.com or https://demo2.nextcloud.com
After 60 minutes the account will be deleted.

There you can get the experience of a “normal” nextcloud.

Thank you devnull for your reply and for trying to help.

NExtcloud recommends running the cron job every 5 minutes.
However, my webhosting offers the possibility to run a cron job only every hour.

What should I do (and why) ?! Keep running AJAX or go for cron with a longer time interval between jobs execution ???

Best,
V

I think with AJAX every user how contacts the Nextcloud triggers Nextcloud to execute a part of schedulling of regular processes. I think that is not bad on a smal instances.

Background tasks are important so don’t ignore the system messages.

AJAX is not ideal because it “executes one task with each page loaded” so it only runs when you access Nextcloud through the web. If you primarily use Nextcloud for file storage and utilize Nextcloud sync to sync your files locally then you likely rarely use your Nextcloud webpage and your background tasks will rarely run. I manage a few Nextcloud instances and one corporate client didn’t have their tasks run for over three month because no-one uses the web for access.

Nextcloud Cron is preferred and is set within the VM. I’m not sure if your shared webhosting Cron settings will work for Nextcloud because I’ve only set them directly on a VM using the command line.

Do you have access to the command line on your shared webhosting? If not you should migrate your Nextcloud instance to DigitalOcean or something similar, roll up your sleeves and tweak your system using the command line. You’re going to run into more issues in the future so it’s best to move now.

Thank you Mainland for your reply.

Yes my webhosting offers cron jobs, but the shortest time interval between running 2 jobs is 1 hour, while Nextcloud recommends running cron.php every 5 minutes…

So basically I would like to know which alternative is better:

  • use AJAX

  • use cron and running a cron job executing cron.php every hour only…

Unfortunately, it does not seem to be easy to answer this question…

It is also unclear how I would notice any drawback of using either alternative.

Best,

Vincent

Running Cron every hour is preferable to executing based on page views using the default AJAX. If you use AJAX and don’t access your Nextcloud webpage over several days no background tasks will run during that time of inactivity.

I’d strongly recommend you look at a service such as DigitalOcean (or linode) for direct VM access. These services provide static IPs and access to the command line for configuring your system. As mentioned, I run several instances of Nextcloud on a bare metal dedicated server and little issues come up like this that require command line access so you’ll save yourself a lot of trouble by switching providers. The providers usually offer an initial credit (usually $100) when opening an account so look for credits before committing so you can try them out for free for a while.

Thank you Mainland for your reply.

Yes my webhosting offers cron jobs, but the shortest time interval between running 2 jobs is 1 hour, while Nextcloud recommends running cron.php every 5 minutes…

So basically I would like to know which alternative is better:

  • use AJAX
  • use cron and running a cron job executing cron.php every hour only…

Unfortunately, it does not seem to be easy to answer this question…
It is also unclear how I would notice any drawback of using either alternative.

Best,
Vincent

If those are your only choices then Cron running ever hour is better than AJAX executing background tasks on every page load.