OCC "command not found" or "Command is not defined"

When I try to run a OCC command, I get the error message “command not found”


$ sudo -u www-data nextcloud.occ files:scan --all
sudo: nextcloud.occ: command not found

How to fix?

Please see official docs. occ command is well documented.

In short words: occ command has to be called via php.

If you cannot match the tutorial you followed with official nextcloud docs, you can install mlocate, run a updatedb by sudo, then locate occ to find where you had put your occ to.

$ sudo apt update
$ sudo apt install mlocate
$ sudo updatedb
$ locate occ

sudo -u www-run php /var/www/html/occ bombo:klat

1 Like

For other people getting an php version error, you probably have to point to the right php version folder manualy:

/usr/bin/php7.1 /home/sites/siteXY/web/nextcloud/occ maintenance:mode --on

1 Like

It’s been a while, but I faced same issue in latest Nextcloud releases. Check, if you had enabled maintenance-mode occ maintenance:mode --on
This was in my case. So turn off maintenance-mode occ maintenance:mode --off, you can access the occ files:scan --all command.
I don’t know the reason, but in active maintenance-mode, you do not have the files-commands available. :thinking:

It is not the same. See syntax of first poster.

1 Like

@wook in maintenance mode the databe is disabled, therefore the commands that need acces to the database doesn’t work.

1 Like

Oh sorry… you are right. Didn‘t read carefully.

1 Like