Cannot Delete File

I’m on version 9. One of my users wants to delete a file and cannot. I was able to get on the server using ssh and go to the directory where the file is located and delete it on the command line. However, the file still shows up in the users web interface and when he tries to delete it, there is an small window which says “Error deleting file”. Any ideas how to correct this?

sudo -u www-data php occ files:scan --all

do that from the root of next cloud, instead --all you can use the username

This problem should be fixed in NC 10.

My Nextcloud installation says “Could not open input file: occ”

What does the "occ"stand for? the folder name?

occ is a script in your NextCloud installation Folder. First you must go into you NC directory.
Or else run the command line with the full NextCloud Directory. In Debian based Server, it should be something like:

sudo -u www-data php /var/www/nextcloud/occ files:scan --all

1 Like

Thanks! I think I finally got an understanding :slight_smile:

I’m on version 11 (upgraded from ownCloud 9 then to Nextcloud 10). Still I have this nasty "Error deleting file" from the web interface.
Like so many time I tried to truncate the table oc_file_locks or the oc_filecache without success.
I cannot proceed to a scan getting : _This version of Nextcloud requires at least PHP 5.6.0 You are currently running 5.4.45-0+deb7u6.
Could it be the reason ?

Can be. NC 11 requires php 5.6 or later.

Ok, Thanks tflidd.
I think that I will consider coming back to ownCloud.
There too many issues with NextCloud with the MacOS client 10.7 not supported by NextCloud.

That won’t be different with ownCloud, the next major release will drop php 5.5 and 5.4 support as well: I can’t tell much about the client as I’m still using the original one with different setups (OC and NC).

I’m experiencing the same issue with NC 13.0.6 and ONE single file is preventing file sync. Again, it can’t be deleted. I’ve run the aforementioned commands in mysql, ran occ files:scan --all and even attempted disabling file locking in config.php

I’m drawing a blank.

Again, this ONE file is preventing sync and guess what? When I cd into the data directory, it’s NOT there. Yes, it’s really odd and it’s really getting on my nerves.

Ubuntu 16.04


I think I found a way to have the deleted files at least not appear in the client anymore.

Beware that I may have broken everything so do it at your own risks.

First I deleted the rogue file from the server by logging in my FTP.
It still appeared in the clients (both web based and iOS app)

So I logged in the nextcloud database (MySQL admin)
Found the oc_file_locks table
Then saw that one entry had the lock set to 1.
I set it to 0.

The file disappeared from the client and so far didn’t bother me anymore.

Maybe it will help some who can’t access the server as root.


thanks for this advice.
But that’s kind of bruteforcing a result… and I’d be very careful to just change or delete values directly in the database.

btw @rhua is concerned about that solution as well.