Cron in nextcloud Scale Cobia Beta.1

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Hello, I understand that there were modifications and I don't know how to change docker to kuber but I would like to see how to configure the cron for nextcloud for this new version of scale beta.1

In scale 22 use this reference

But now... the command "docker ps | grep nextcloud" does not work for me, when updating I would like to know what the new one would be and how to configure the new cron for nextcloud

Scale 22
docker exec --user root `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php cron.php
Sin título.png




Scale 23
?¿???
1692498076330.png
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
I am not running Cobia. However, another way to execute a command in a container without docker command which was removed, at least in 22 Scale is:

k3s kubectl exec -n ix-nextcloud --stdin --tty "$(/usr/local/bin/k3s kubectl -n ix-nextcloud get pods --field-selector status.phase=Running -o name | cut -f2 -d'/')" -- su -s /bin/bash www-data -c 'php occ maintenance:mode --on'

You can replace the php maintenance command with cron most likely, give it a try. I'm curious so let me know. kubectl doesn't support directly a run as user option.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
I am not running Cobia. However, another way to execute a command in a container without docker command which was removed, at least in 22 Scale is:

k3s kubectl exec -n ix-nextcloud --stdin --tty "$(/usr/local/bin/k3s kubectl -n ix-nextcloud get pods --field-selector status.phase=Running -o name | cut -f2 -d'/')" -- su -s /bin/bash www-data -c 'php occ maintenance:mode --on'

You can replace the php maintenance command with cron most likely, give it a try. I'm curious so let me know. kubectl doesn't support directly a run as user option.
k3s kubectl exec -n ix-nextcloud --stdin --tty "$(/usr/local/bin/k3s kubectl -n ix-nextcloud get pods --field-selector status.phase=Running -o name | cut -f2 -d'/')" -- su -s /bin/bash www-data -c 'php cron.php'


k3s kubectl exec -n ix-nextcloud --stdin --tty "$(/usr/local/bin/k3s kubectl -n ix-nextcloud get pods --field-selector status.phase=Running -o name | cut -f2 -d'/')" -- su -s /bin/bash root -c 'php cron.php'

:frown::frown::frown:
Error: [EFAULT] CronTask "k3s kubectl exec -n ix-nextcloud --stdin --tty "$(/usr/local/bin/k3s kubectl -n ix-nextcloud get pods --field-selector status.phase=Running -o name | cut -f2 -d'/')" -- su -s /bin/bash root -c 'php cron.php' > /dev/null" exited with 1 (non-zero) exit status.
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Likely a way to make it work but as I don't have a Cobia, can't play with each piece of the command. Forgetting using it in cron, did you try via command line from truenas (not container) shell?
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Probablemente sea una forma de hacerlo funcionar, pero como no tengo un Cobia, no puedo jugar con cada pieza del comando. Olvidando usarlo en cron, ¿intentó a través de la línea de comando desde el shell truenas (no contenedor)?

the documentation according to nextcloud gives me these steps



try even adding said commands inside the pod itself
 
Last edited:

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
True, but that's not with kubernetes/Truenas. Sorry I can't play with it myself to make it work in Cobia.

I don't believe cron runs in the container at all, without supervisord. I use a modified version of the docker container, based on this dockerfile setup:


And then use load docker image button to load my custom image.

The readme was here:


Which explains.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
True, but that's not with kubernetes/Truenas. Sorry I can't play with it myself to make it work in Cobia.

I don't believe cron runs in the container at all, without supervisord. I use a modified version of the docker container, based on this dockerfile setup:


And then use load docker image button to load my custom image.

The readme was here:


Which explains.
Get by modifying the command of this post a half response


and I started using commands

k3s kubectl get namespaces -o name | grep nextcloud

and I adapted it guiding me from the failures but I did not finish fine-tuning it by changing my user to root

k3s kubectl get -o name -n nextcloud_nextcloud pods | sed -r "s/pod\///g" | xargs -I{} k3s kubectl exec -n nextcloud_nextcloud --stdin --tty {} -- su -s /bin/bash root -c 'php cron.php'

he swallows it but it must not be right


1692554412838.png
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Maybe it worked, I'll be watching


1692554649078.png



With this

k3s kubectl get -o name -n ix-nextcloud pods | sed -r "s/pod\///g" | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- su -s /bin/bash root -c 'php cron.php'

1692554987301.png


although maybe with errors
 
Last edited:

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
My container runs as www-data, the default one. But maybe yours is running as root. It does appear it worked. I will apparently be fine tuning my kubectl commands for Cobia! What I sent you works fine under Truenas before Cobia.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
My container runs as www-data, the default one. But maybe yours is running as root. It does appear it worked. I will apparently be fine tuning my kubectl commands for Cobia! What I sent you works fine under Truenas before Cobia.
Yes, I rely on the installation as shown in the cron user root



Sin título.png



It's funny, it must be the wrong command, but it does what it should xD


k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- su -s /bin/bash root -c 'php cron.php'

1692556330609.png


1692555493393.png
 
Last edited:

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Try shortening it to:

k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- php cron.php

You shouldn't need the su portion as you should already be root in the container if I understand you correctly. May or may not get rid of exit code.

My command was checking for pod status running. The reason was here and there, I'd find failed pods so there would be multiple ones. This would make the command fail. So, I ignored them with my version of the command. If you never have failed pods, won't matter.

Glad you got it working though.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Try shortening it to:

k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- php cron.php

You shouldn't need the su portion as you should already be root in the container if I understand you correctly. May or may not get rid of exit code.

My command was checking for pod status running. The reason was here and there, I'd find failed pods so there would be multiple ones. This would make the command fail. So, I ignored them with my version of the command. If you never have failed pods, won't matter.

Glad you got it working though.


It works the same, but with the same error


1692569692548.png
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
It might be worth saying that all 3 of the options for Background Jobs in Nextcloud are intended to be run from within the container, not outside it.

Can't you use Webcron instead? or investigate why the cron job isn't running properly from inside the container?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
Consider the last part in the command you're trying:

php cron.php

I imagine the system will need context to know where both of those components are, so specifying the paths, not just the filenames would probably help.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Consider the last part in the command you're trying:

php cron.php

I imagine the system will need context to know where both of those components are, so specifying the paths, not just the filenames would probably help.
Apparently I did not find the correct key, inside the nextcloud jail there is a section called cron because it automatically calls it every 5 minutes but it asks you for the command, try putting it in that section, both with the path and the full path, like the path it finds from the shell like simply invoking it and the same result but with the error showing the path that it uses at that moment

1692620808394.png


1692620778960.png



routes used

php /html/cron.php
php cron.php
php /nextclouddatos/html/cron.php
cron.php
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
It might be worth saying that all 3 of the options for Background Jobs in Nextcloud are intended to be run from within the container, not outside it.

Can't you use Webcron instead? or investigate why the cron job isn't running properly from inside the container?

I have been using it too, from a website that calls cron every 5 minutes but it seems that nextcloud does not work well and the internal administration panel shows that it is not running, even if I do it manually I eat the website



1692621080550.png




Web

 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
Based on the error, I see that cron.php is expecting some more information from the command to call it...

But it's not clear from what you showed above that you're trying the command in the existing container now...

Are you running the command like this?

k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- php /pnextclouddatos/html/cron.php

From the shell of TrueNAS?
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Cron is not running in docker. Docker starts a single process. That process is nextcloud (web). Without changes to the dockerfile, there is no cron. If you do a ps, no cron. That's why. I modify the dockerfile from hub.docker to run supervisord as mentioned earlier in the thread to instead run supervisord, which in turn runs nextcloud (apache) and crond. Then it works fine. The suggested changes are on github.

If sretalia is interested in more whys, read here:


They actually expect you to run a separate docker container for cron. Honestly though, the "app" for Scale as given by IX Systems should include the modified version of the nextcloud docker than includes cron. IX doesn't provide a cron "app". It's really not that difficult to change the dockerfile and include supervisord.
 
Last edited:

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
both


1692632180795.png


k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- php cron.php

1692632246637.png



but it only works from the truenas gui with this command, even if there is an error, it executes it

k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- php cron.php
 
Last edited:

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Based on the error, I see that cron.php is expecting some more information from the command to call it...

But it's not clear from what you showed above that you're trying the command in the existing container now...

Are you running the command like this?

k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- php /pnextclouddatos/html/cron.php

From the shell of TrueNAS?
1692632960815.png
 
Top