Automatic deletion of old files?

Hi all,

we use nextcloud to provide files to our customers. Those files are downloaded once and will never be needed again.

My plan is to create a script, which deletes all files older than 3 days from the nextcloud storage.

Unfortunately, I’m neither a linux specialist nor versed in any nextcloud configurations. Our linux admin left the company, you can imagine it’s quite hard for me (as a Windows admin) to get into this topic.

I found this site: https://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/ Is this the right method for me or doesn’t it work for nextcloud?

If possible, I want to use that command in a script which runs automatically every day.

Thank you very much
BR, Phil :grinning:

Understand what you’re trying to achieve though surely this will be very messy as the nextcloud database will say one thing and the filesystem another.

Why not just use the retention plugin and set it to three days?

https://apps.nextcloud.com/apps/files_retention

2 Likes

Well that’s why I said that im not versed with this :smile: I didn’t even know, there was a plugin for my demand.

Thank you very much Dan, I will try to get this working.

No problem, there are loads of plugins for integration with other systems, management tasks etc.

I can see that Retention is already active - but where can I configure its settings? Im logged in with ncadmin.

You can find the settings under “Admin” (where you configure everything) under the point “Workflow”.
Down on that page you see “File retention” then.

There you will also see the configuration of “Files automated tagging” what you would need. So you define to automatically tag files and files with these tags will be deleted after a defined time. Pretty nice this feature :slight_smile:

Thank you Schmu :slight_smile:

So if I want all files to be deleted automatically 14 days after uploading, this is the correct way, isn’t it?

That would work, yes.
But be aware and maybe double-check: now absolutely every file will be auto-tagged unless it is bigger than 100 GB. Are you sure you will never have any other file on the server which you would like to keep?

Just mentioning so that there will be no bad surprise :slight_smile:

Thank you very much :slight_smile: It should be fine that way, at least I know how to change it if the requirements will change in the future.