- Joined
- Jan 1, 2016
- Messages
- 9,700
So that's telling you why you can't run it... there's no PATH variable, so you need to specify the full path to php also.
But as is already mentioned by @sfatula the cron service isn't there in the container, so what you're trying to run won't work even when you get it to run.
You'll need to work out where php is in the container.
You can go to the shell of the container and typewhich php
(assuming the shell gets a good path), or maybe you'll need to find it withfind / -name php
k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- /usr/local/bin/php /nextclouddatos/html/cron.php
Así que ahí lo tienes...
k3s kubectl get -o nombre -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- /usr/local/bin/php /nextclouddatos/html/cron.php
Pero como se mencionó, se espera que esto no funcione ya que cron no está en el contenedor.
k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- /usr/local/bin/php cron.php
That is expected to work actually. What is not expected to work within the container is a an actual cron job to run that command. The php program named cron.php does not run or use cron. It is merely what one would normally run every few minutes in a cron job. Since nextcloud has no crond running, you have to run it somehow and one somehow is externally.So there you have it...
k3s kubectl get -o name -n ix-nextcloud pods | xargs -I{} k3s kubectl exec -n ix-nextcloud --stdin --tty {} -- /usr/local/bin/php /nextclouddatos/html/cron.php
But as mentioned, this is expected not to work since cron isn't in the container.
thxIssue created:
![]()
Nextcloud really should have crond in the container · Issue #1472 · truenas/charts
Nextcloud really relies a lot on having crond. Knowledgeable users currently are generally executing docker commands in truenas which run php cron.php within the container as a kluge. This is after...github.com
Thanks!
Edit, looks like this has already been handled in 23.10:
![]()
[Issue] NextCloud Application - Cron background job not working · Issue #1306 · truenas/charts
Hi ! This issue report is tied to discussion on TN Forum : https://www.truenas.com/community/threads/nextcloud-moved-from-truecharts-back-to-official.110820/ Context TrueNAS-SCALE-22.12.3.1 NextClo...github.com
Upgrading TrueNAS Scale from 22.12.4.2 Bluefin to 23.10 Cobia gave me the same issue.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
TrueNAS Scale Nextcloud cron not working
Hello! Read a few posts about this problem but no solution found yet... I am running: TrueNAS-SCALE-22.02.2.1 Nextcloud app 24.0.3_1.6.6 Cannot get the cron job to work. The settings in the app is as follows: CronJob configuration Setup cronjob for nextcloud Enable cronjobs for nextcloud...www.truenas.com
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
View attachment 69459
Scale 23
?¿???
View attachment 69458
docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php -d memory_limit=-1 -f /var/www/html/cron.php
k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'` -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/cron.php'
docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php -d memory_limit=-1 -f /var/www/html/occ preview:pre-generate
k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'` -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/occ preview:pre-generate'
-i
-it
-t
option instructs kubectrl exec to use your current TTY console as output. Since cron does not have a TTY console, you omit the -t option in the cron command. If you don't your command will execute but will show an error message "Unable to use a TTY - input is not a terminal or the right kind of file".perfect!! I will try itLa actualización de TrueNAS Scale de 22.12.4.2 Bluefin a 23.10 Cobia me dio el mismo problema.
Pude solucionarlo. Quizás lo que hice también pueda ayudarte a ti y a otros.
Mi comando cron TrueNAS Scale para Nextcloud Cron
Atún rojo:
[CÓDIGO]docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ imprimir $1; }'` php -d límite_memoria=-1 -f /var/www/html/cron.php[/CODE]
cobia:
[CÓDIGO]k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'siguiente nube-[0-9]' | awk '{ imprimir $1; }'` -- su -s /bin/bash www-data -c 'php -d límite_memoria=-1 -f /var/www/html/cron.php'[/CODE]
Mi comando cron TrueNAS Scale para el generador de vista previa de Nextcloud
Atún rojo:
[CÓDIGO]docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ imprimir $1; }'` php -d Memory_limit=-1 -f /var/www/html/occ vista previa:pregenerar[/CODE]
cobia:
[CÓDIGO]k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'siguiente nube-[0-9]' | awk '{ imprimir $1; }'` -- su -s /bin/bash www-data -c 'php -d Memory_limit=-1 -f /var/www/html/occ vista previa:pregenerar'[/CODE]
Solo Cobia: cuando quieras probar tu comando cron
Si desea probar su comando cron en la consola TrueNAS Scale
cambiar
[CÓDIGO]-i[/CÓDIGO]
a
[CÓDIGO]-it[/CÓDIGO]
La opción-t
le indica a kubectrl exec que use su consola TTY actual como salida. Como cron no tiene una consola TTY, omite la opción -t en el comando cron. Si no lo hace, su comando se ejecutará pero mostrará un mensaje de error "No se puede usar un TTY: la entrada no es una terminal o el tipo de archivo correcto".
johan
Console has to be executed with the user that owns the file config/config.phpUpgrading TrueNAS Scale from 22.12.4.2 Bluefin to 23.10 Cobia gave me the same issue.
I was able to solve it. Maybe what I did can also help you and others.
My TrueNAS Scale cron command for Nextcloud Cron
Bluefin:
Code:docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php -d memory_limit=-1 -f /var/www/html/cron.php
Cobia:
Code:k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'` -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/cron.php'
My TrueNAS Scale cron command for Nextcloud Preview generator
Bluefin:
Code:docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php -d memory_limit=-1 -f /var/www/html/occ preview:pre-generate
Cobia:
Code:k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'` -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/occ preview:pre-generate'
Cobia only: When you want to test your cron command
If you want to test your cron command in the TrueNAS Scale console
change
Code:-i
to
Code:-it
The-t
option instructs kubectrl exec to use your current TTY console as output. Since cron does not have a TTY console, you omit the -t option in the cron command. If you don't your command will execute but will show an error message "Unable to use a TTY - input is not a terminal or the right kind of file".
Johan
Thanks, that's exactly what I was looking for. It works greatUpgrading TrueNAS Scale from 22.12.4.2 Bluefin to 23.10 Cobia gave me the same issue.
I was able to solve it. Maybe what I did can also help you and others.
My TrueNAS Scale cron command for Nextcloud Cron
Bluefin:
Code:docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php -d memory_limit=-1 -f /var/www/html/cron.php
Cobia:
Code:k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'` -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/cron.php'
My TrueNAS Scale cron command for Nextcloud Preview generator
Bluefin:
Code:docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php -d memory_limit=-1 -f /var/www/html/occ preview:pre-generate
Cobia:
Code:k3s kubectl exec -n ix-nextcloud -c nextcloud -i `k3s kubectl get -o wide -n ix-nextcloud pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'` -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/occ preview:pre-generate'
Cobia only: When you want to test your cron command
If you want to test your cron command in the TrueNAS Scale console
change
Code:-i
to
Code:-it
The-t
option instructs kubectrl exec to use your current TTY console as output. Since cron does not have a TTY console, you omit the -t option in the cron command. If you don't your command will execute but will show an error message "Unable to use a TTY - input is not a terminal or the right kind of file".
Johan
I can't run cron anymore, before with errors at least it workedConsole has to be executed with the user that owns the file config/config.php
Current user id: 33
Owner id of config.php: 3001
command terminated with exit code 1
;(
NEXTCLOUDPOD=$(k3s kubectl get -o wide -n ix-nextcloud --field-selector=status.phase==Running pods | grep 'nextcloud-[0-9]' | awk '{ print $1; }'); k3s kubectl exec -n ix-nextcloud -c nextcloud -i "$NEXTCLOUDPOD" -- su -s /bin/bash www-data -c 'php -d memory_limit=-1 -f /var/www/html/cron.php'
Then run this to add the indices, where nextcloud-7c84b8bbf-m4k9r is the pod name got from last command.k3s kubectl get pods -A | grep nextcloud
k3s kubectl exec -n ix-nextcloud --stdin --tty nextcloud-7c84b8bbf-m4k9r -- su -s /bin/bash www-data -c 'php occ db:add-missing-indices'