Nextcloud & TrueNAS cron setting

I’ve recently installed the Nextcloud plugin on my TrueNAS 12.1 Beta2 and I’m having a difficult time trying to set up the cron settings for Nextcloud. Using the terminal, I’ve added the following to crontab

crontab -u www -e

and added the following lines

*/5 * * * * /usr/local/bin/php -f /usr/local/www.nextcloud/cron.php

From there I verified that the job was scheduled by typing

crontab -u www -l

where I received the following

*/5 * * * * /usr/local/bin/php -f /usr/local/www.nextcloud/cron.php

However, when I go to check the status in my Nextcloud instance I’m notifed that the

I’ve tried running the cron job manually by executing the following code in the Nextcloud jail terminal

#su -m www /usr/local/bin/php -f /usr/local/www/nextcloud/cron.php

Unofortunately when I run that command the terminal appears to lock up and not do anything. If I pull up top I can’t see any specific process tied to that command.

Am I doing something wrong, or does anyone have any further troubleshooting/tips that I can try? Thanks in advance!

I tried making the cron.php executible (chmod 720), and now I’m receiving the following errors.

root@Nextcloud:/usr/local/www/nextcloud # chmod 720 cron.php
root@Nextcloud:/usr/local/www/nextcloud # ls -la cron*
-rwx-w----  1 www   www  5140 Jul 15 13:22 cron.php
root@Nextcloud:/usr/local/www/nextcloud # su -m www /usr/local/bin/php -f /usr/local/www/nextcloud/cron.php
^?ELF^B^A^A: Command not found.
Too many )'s.
root@Nextcloud:/usr/local/www/nextcloud #```
1 Like

I assume that “-u www-data” and later “-u www” is a typo.

I run ownCloud not nextcoud but could check how I have corn setup in the morning if that’s any help.

Yeah, that was a copy/paste typo. I corrected it.

I appreciate you looking at your config. I’m assuming that it’s the same setup.

Ok, so my cron entry for www-data looks quite different

*/15 * * * * /var/www/ system:cron

If the system you are talking about isn’t production or you have good backups then maybe try running the above (OCC is Own Cloud Control so I guess it might be ncc?)

You could try running it as from root with su as www-root as well to see if that helps.

When you run the command and it locks up do you get anything in the PHP logs?

Could be worth dropping a */5 * * * * echo '$date "+%FT%T" ' >> /tmp/testcron.log (touch /tmp/testcron.log first maybe) or something similar to make sure the users cron is actually running
(the above command might need some tweaking I’ve not actually run it)

1 Like

Thanks for responding. It looks like I was able to get it working after several more hours of trial and error. What I ended up adding was the following line:

*/5 * * * * /usr/local/bin/php -f /usr/local/www/nextcloud/cron.php

Before posting I thought that I had tried that exact command but now that I have that running, I have the green light from Nextcloud.

1 Like