TrueNAS Scale Nextcloud cron not working

enghult

Cadet
Joined
Jul 28, 2022
Messages
6
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 [enabled]
Schedule
1 */24 * * *

The storage pool for nextcloud is set up with:
User root
Group apps

both have read, write and execute permissions
www-data is member in group apps
 

aherbjornsen

Dabbler
Joined
Dec 7, 2014
Messages
15
I fixed this by adding a cron job (in TrueNAS GUI, under "System settings->Advanced"), running the appropriate command via docker every 10 minutes.

The command I run in cron is this, should be pretty generic:

docker exec --user www-data `docker ps | grep "ix-chart_nextcloud" | awk '{ print $1; }'` php /var/www/html/cron.php
 

enghult

Cadet
Joined
Jul 28, 2022
Messages
6
Thx for the reply!

Got this error by mail (run @ user root)
Error: No such container: php

Is "ix-chart_nextcloud" the supposed container name?

I did a restart of TruNAS. Not sure if it helped.

Can see this error in the apps "pod log":

2022-07-29 12:15:12.115564+00:00% Total % Received % Xferd Average Speed Time Time Time Current
2022-07-29 12:15:12.115615+00:00Dload Upload Total Spent Left Speed
2022-07-29 12:15:12.439719+00:000 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 157 100 157 0 0 484 0 --:--:-- --:--:-- --:--:-- 484
2022-07-29 12:15:12.439868+00:00<html>
2022-07-29 12:15:12.439878+00:00<head><title>502 Bad Gateway</title></head>
2022-07-29 12:15:12.439886+00:00<body>
2022-07-29 12:15:12.439893+00:00<center><h1>502 Bad Gateway</h1></center>
2022-07-29 12:15:12.439900+00:00<hr><center>nginx/1.21.3</center>
2022-07-29 12:15:12.439911+00:00</body>
2022-07-29 12:15:12.439919+00:00</html>
 

aherbjornsen

Dabbler
Joined
Dec 7, 2014
Messages
15
No, "ix-chart_nextcloud" is part of the container name, which I use to get the correct container id for the "docker exec" command.

I run the standard docker version of nextcloud, if you run the Truecharts version you might need to search for something else.

If I run "docker ps | grep nextcloud" in a shell I see this:

[~]# docker ps | grep nextcloud
9d59ab190564 cc45052d6b45 "/entrypoint.sh apac…" 2 days ago Up 2 days k8s_ix-chart_nextcloud-ix-chart-7ddf56d778-mxxld_ix-nextcloud_fedbab05-c9b5-49d7-b0c7-a8e7aeb209f7_0
dd830fc67f00 rancher/mirrored-pause:3.6 "/pause" 2 days ago Up 2 days k8s_POD_nextcloud-ix-chart-7ddf56d778-mxxld_ix-nextcloud_fedbab05-c9b5-49d7-b0c7-a8e7aeb209f
You possibly get something else, and need to search for that?
 

enghult

Cadet
Joined
Jul 28, 2022
Messages
6
Fantastic!! :smile:
I got this:

docker ps | grep nextcloud
f15ced8eb4cc cc45052d6b45 "/entrypoint.sh apac…" 4 hours ago Up 4 hours k8s_nextcloud_nextcloud3-576559bb6f-cvxh6_ix-nextcloud3_e96ebe22-0b23-405c-8170-1cb634b06746_1
f2c0dd0967f5 87a94228f133 "/docker-entrypoint.…" 4 hours ago Up 4 hours k8s_nginx_nextcloud3-576559bb6f-cvxh6_ix-nextcloud3_e96ebe22-0b23-405c-8170-1cb634b06746_1
0fad8c2ca095 407cece1abff "docker-entrypoint.s…" 4 hours ago Up 4 hours k8s_nextcloud-postgres_nextcloud3-postgres-65b866949b-dd5n8_ix-nextcloud3_8770473c-d285-4f55-8064-be97da073ae6_1
dabf60762d60 rancher/mirrored-pause:3.6 "/pause" 4 hours ago Up 4 hours k8s_POD_nextcloud3-576559bb6f-cvxh6_ix-nextcloud3_e96ebe22-0b23-405c-8170-1cb634b06746_1
ee8741d5359c rancher/mirrored-pause:3.6 "/pause" 4 hours ago Up 4 hours k8s_POD_nextcloud3-postgres-65b866949b-dd5n8_ix-nextcloud3_8770473c-d285-4f55-8064-be97da073ae6_1

So I changed my cron command to:

docker exec --user www-data `docker ps | grep "nextcloud_nextcloud3" | awk '{ print $1; }'` php /var/www/html/cron.php
and it worked!
Thanks a lot!
 

ApexProxy

Dabbler
Joined
Dec 22, 2022
Messages
19
I have been struggling with getting cron to run all day. I finally got it to work after I followed the info here plus I figured out that with the current version of Scale I had to select Run As User: root to get it to work. This is my setup for anyone who runs across this in the future.

My final cron command is:
docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php /var/www/html/cron.php

Screenshot 2022-12-22 172533.png


I am so happy this is working, thanks for everything in this post.
 

tziegler

Dabbler
Joined
Sep 18, 2022
Messages
10
Hello I got the same Problem and tried your command but i did not get it to work. ( I'm a total beginer at this)
my command : docker exec --user www-data `docker ps | grep "nextcloud" | awk '{print $1;}'` php /var/www/html/cron.php
the error I get: [EFAULT] CronTask "docker exec --user www-data `docker ps | grep "nextcloud" | awk '{print $1;}'` php /var/www/html/cron.php > /dev/null" exited with 126 (non-zero) exit status.
I don't now which info would be helpful. If you need more info let me now.
Thank you already for your help!
 
Joined
Mar 22, 2020
Messages
61
Hello I got the same Problem and tried your command but i did not get it to work. ( I'm a total beginer at this)
my command : docker exec --user www-data `docker ps | grep "nextcloud" | awk '{print $1;}'` php /var/www/html/cron.php
the error I get: [EFAULT] CronTask "docker exec --user www-data `docker ps | grep "nextcloud" | awk '{print $1;}'` php /var/www/html/cron.php > /dev/null" exited with 126 (non-zero) exit status.
I don't now which info would be helpful. If you need more info let me now.
Thank you already for your help!
Try with grep ”nextcloud_nextcloud” instead
 

linux_jasky

Cadet
Joined
Mar 6, 2023
Messages
1
TrueNAS GUI, under "System settings->Advanced" then the command that worked for me:

Code:
docker ps  | grep "k8s_nextcloud_nextcloud" | awk '{ print $1; }' | xargs -I % docker exec --user www-data "%" php -f /var/www/html/cron.php


`docker ps` -- lists current running containers
`grep "k8s_nextcloud_nextcloud"` -- grabs the line with the container id of nextcloud
`awk '{ print $1; }'` -- gets the first column of that line (the one with the id in it)
`xargs -I % docker exec --user www-data "%" php -f var/www/html/cron.php` -- xargs is used to template the container id into the right place and then docker runs as the `www-data` user to run the php cron file at /var/www/html/cron.php (inside the nextcloud container)
 

dfigueire

Cadet
Joined
Mar 18, 2023
Messages
1
docker ps | grep "k8s_nextcloud_nextcloud" | awk '{ print $1; }' | xargs -I % docker exec --user www-data "%" php -f /var/www/html/cron.php

Just wanted to update others. I also used this command and it works. I do hope the original issue (so we can configure cron in the nextcloud edit panel) is resolved. Thanks to all here.
 

frankyvee

Cadet
Joined
Mar 8, 2023
Messages
6
I have been struggling with getting cron to run all day. I finally got it to work after I followed the info here plus I figured out that with the current version of Scale I had to select Run As User: root to get it to work. This is my setup for anyone who runs across this in the future.

My final cron command is:
docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php /var/www/html/cron.php

View attachment 61400

I am so happy this is working, thanks for everything in this post.
This command line actually worked for me. I did not get an error emailed to me. Also when I looked at Nextcloud Basic Settings it shows the Cron Job ran successfully and it's green. Thank You for posting this fix.
 

Attachments

  • Screenshot 2023-03-21 011726.jpg
    Screenshot 2023-03-21 011726.jpg
    96.4 KB · Views: 508

TYFLOOZY

Dabbler
Joined
Mar 25, 2023
Messages
30
I have been trying to install the Official Nextcloud just how THIS video suggests, but does not go into setting up a Cron Job. He checks adds the certificate, selects the Data Set that was previously configured, and selects the "Enable cronjobs for nextcloud" option. Whenever I follow this I always get the error that says "Error: [EINVAL] values.cronjob.schedule: Not a string"

Screenshot 2023-03-25 201237.png



So I've been searching the web on how to make this work and found all sorts of commands and tried the above Commands but nothing has worked it. This is my first time using Truenas Scale and Nexcloud. I tried playing with the pre-configured schedule of "1 */24 * * *" but that hasn't worked as well. This is where the Cron Job is currently set at:


Screenshot 2023-03-25 201507.png


Any help is a appreciated!

PS: I did get NexCloud to install the first time, but I didnt mess with the credentials or cron. I'm not sure if I need Cron or not, but that video I linked said did.
 
Joined
Mar 22, 2020
Messages
61
Its a bug introduced in the last release. It will be fixed in the next release in april As far as i have understood
 

TYFLOOZY

Dabbler
Joined
Mar 25, 2023
Messages
30
Thank you for the heads up! I'm guessing it's not a good idea to try and "Roll Back" on the truenas release? Also, Could I install NextCloud and just turn on/enable cron jobs later on? My fear is installing the software, using it for a while and then having to start over because of a setting that I'd like to have turned on. Lastly, I was curious on what this specific Cron Job actually does? Like what is its task?

I appreciate it!
 
Joined
Mar 22, 2020
Messages
61
Thank you for the heads up! I'm guessing it's not a good idea to try and "Roll Back" on the truenas release? Also, Could I install NextCloud and just turn on/enable cron jobs later on? My fear is installing the software, using it for a while and then having to start over because of a setting that I'd like to have turned on. Lastly, I was curious on what this specific Cron Job actually does? Like what is its task?

I appreciate it!
No problem to install Nextcloud and enable cron later as far as I know. I have had it lake that for several months earlier due to another problem. Not sure of all the things that the cron job does but one thing I know is that it updates the map with photo gps coordinates and also the recognize module needs cron. Havent seen any more problem without running the cron job but I'm not sure
 

frankyvee

Cadet
Joined
Mar 8, 2023
Messages
6
It's a bug and a shame they didn't catch it before this release. What I did is left the Cron Job setting blank and enabled it once I got the server installed. Once Next Cloud is installed go to System settings then Advanced then add Cron Job. Enter the following command:
docker exec --user www-data `docker ps | grep "nextcloud_nextcloud" | awk '{ print $1; }'` php /var/www/html/cron.php

For the schedule use custom entry as: */5****
 

frankyvee

Cadet
Joined
Mar 8, 2023
Messages
6
What I noticed if I did not have the schedule as: */5**** It would still error out if it was not set to run every 5 minutes. It's a bit tricky to set the custom schedule to */5***. But I remember adding just one astrisk to one of the filelds and then to a lower field add 5***. You may have to play around with the settings untill you get */5**** in the final custom field.
 
Last edited:

TYFLOOZY

Dabbler
Joined
Mar 25, 2023
Messages
30
Thanks for all the input. I installed NextCloud and then inputted the data above for the cronjob, but can only achieve the schedule of Every 5 Minutes. So unless there is more specific input, I'll have to keep messing with it. I did try and test it out to enable cron schedule after installing the app, and got the following error message.

I'll keep trying out different schedules. I've also noticed that if I do try and "edit" the installation of NextCloud, then the app seems to be stuck in deploying 1/2. Any thoughts there from anyone? What i've done in the past is delete that NextCloud instance and re download. But I'm hoping doing that over and over doesn't ruin anything in the short term.
 

Attachments

  • Screenshot 2023-03-27 200141.png
    Screenshot 2023-03-27 200141.png
    320.3 KB · Views: 429
  • Screenshot 2023-03-27 193945.png
    Screenshot 2023-03-27 193945.png
    147.1 KB · Views: 400
  • Screenshot 2023-03-27 200702.png
    Screenshot 2023-03-27 200702.png
    33.4 KB · Views: 402

frankyvee

Cadet
Joined
Mar 8, 2023
Messages
6
Thanks for all the input. I installed NextCloud and then inputted the data above for the cronjob, but can only achieve the schedule of Every 5 Minutes. So unless there is more specific input, I'll have to keep messing with it. I did try and test it out to enable cron schedule after installing the app, and got the following error message.

I'll keep trying out different schedules. I've also noticed that if I do try and "edit" the installation of NextCloud, then the app seems to be stuck in deploying 1/2. Any thoughts there from anyone? What i've done in the past is delete that NextCloud instance and re download. But I'm hoping doing that over and over doesn't ruin anything in the short term.
That is strange that it is giving you an error. Looks like your entries are correct. Have you looked on your Next Cloud Web Admin page under Administration then Basic Settings and see if the Cron Job is running correctly there?
 

Attachments

  • cronjob.jpg
    cronjob.jpg
    75.6 KB · Views: 520
Top