Nextcloud Rescan Files Occ Command help

Please help me. I’ve spent almost a week trying to transfer files from a hard drive to my yunohost nextcloud via webdav. No matter what i try i get error after error.

Since I can access the physical storage disk of the server I use, I thought it would be easier to transfer them locally, but when I do that, the files don’t appear in nextcloud. I’ve read forums that say I need to rescan the files for them to appear in nextcloud using an occ command. I just can’t figure out how to do that.

If my yunohost nextcloud username is user123, i can ssh into my server and become root and then change directories to /home/

Is this the right directory and if so, what is the command I use to have the files rescanned?

Thank you for helping. I am at my wit’s end.

from my notes:

to use occ command line tool I had to activate “opcache” in php.ini file and apcu.ini module in /etc/php/PHPVERSION/mods-available/apcu.ini

move files to nextcloud folder(s) and


sudo cd /var/www/nextcloud
sudo -u nextcloud PHPVERSION occ files:scan --all

read documentation for "occ files: (-clean up, repair-tree, scan…)

You don’t need it (and I don’t know if it’s advised).
You can activate it just during a command : sudo -u nextcloud PHPVERSION --define apc.enable_cli=1 /var/www/nextcloud/occ.
For reference: Create an occ script to easely launch occ command · Issue #540 · YunoHost-Apps/nextcloud_ynh · GitHub

All parts are important: your execute the command as nextcloud user, using the right php version (8.1 right now), enable apcu cache during the command, and run occ tool (even if you’re not in Nextcloud directory thanks to the absolute path)

1 Like

Hi. The command failed and here is the output from the terminal.

Sorry, user user123 is not allowed to execute ‘/usr/bin/php7.4 --define apc.enable_cli=1 /var/www/nextcloud/occ’ as nextcloud on

I also tried as root by issuing the ‘sudo su’ command and trying again. This time I received the following response:

This version of Nextcloud requires at least PHP 8.0
You are currently running 7.4.3

If you are running the latest version of Nextcloud (the yunohost package I mean), you shouldn’t use php7.4, as it’s php8.1 that is used.
Adjust the command :slight_smile:

Here is the command that eventually worked for me. I ran as root

sudo -u nextcloud php8.1 --define apc.enable_cli=1 /var/www/nextcloud/occ files:scan

It then prompted me to Please specify the user id to scan, --all to scan for all users or --path=…

I chose all so as root issued the following command:

sudo -u nextcloud php8.1 --define apc.enable_cli=1 /var/www/nextcloud/occ files:scan --all

and it worked. Thank you so much for helping me.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.