Nextcloud自动清理回收站

本文档介绍了如何在使用snap安装的Nextcloud中自动清理回收站。通过修改`config/config.php`文件,将`trashbin_retention_obligation`参数设置为`auto,3`,可以实现超过3天的文件自动清理。此设置适用于避免手动频繁清理及节省存储空间。操作涉及Snap命令行使用、Nextcloud配置文件编辑等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Nextcloud自动清理回收站

注意,本文Nextcloud为snap安装的,如果是手动安装也不会麻烦那么多了。然后也没有添加www-data这样的用户对应该Nextcloud的权限,全是管理员权限,如和您安装的方式与设置不一样导致其它bug也是没办法的事。本文仅作自留档,毕竟已经折腾Nextcloud两次了。

首先是如果想手动清空的话,比如以下命令清空所有用户的回收站

sudo nextcloud.occ trashbin:cleanup -all-users

但如果要自动清除呢?以下参考https://www.shenqhy.com/nextcloud-clear-files_trashbin.html

博主的Nextcloud数据放在阿里的NAS下,突发奇想在阿里云手机客户端上查看了下用量,1.5个G,不科学啊。
进入NAS挂载目录,du逐层排查,发现是某账户文件夹下的files_trashbin文件夹占用了1.3个G
天天手动清理不累死
谷歌查找自动清理方法,在Nextcloud文档中发现,通过修改trashbin_retention_obligation参数为'auto,D'可自动清理超过D天的trashbin
遂添加

'trashbin_retention_obligation' => 'auto,3',

auto,3即为超过3天自动清理

保存后等待下一次Cron生效

转载请注明:神奇海域 » Nextcloud清理files_trashbin

官方文档对应部分如下:

Configuration Parameters

Nextcloud uses the config/config.php file to control server operations. config/config.sample.php lists all the configurable parameters within Nextcloud, along with example or default values. This document provides a more detailed reference. Most options are configurable on your Admin page, so it is usually not necessary to edit config/config.php.

Note

The installer creates a configuration containing the essential parameters. Only manually add configuration parameters to config/config.php if you need to use a special value for a parameter. Do not copy everything from config/config.sample.php . Only enter the parameters you wish to modify!

Deleted Items (trash bin)

These parameters control the Deleted files app.

'trashbin_retention_obligation' => 'auto',

If the trash bin app is enabled (default), this setting defines the policy for when files and folders in the trash bin will be permanently deleted.

The app allows for two settings, a minimum time for trash bin retention, and a maximum time for trash bin retention. Minimum time is the number of days a file will be kept, after which it may be deleted. Maximum time is the number of days at which it is guaranteed to be deleted. Both minimum and maximum times can be set together to explicitly define file and folder deletion. For migration purposes, this setting is installed initially set to “auto”, which is equivalent to the default setting in Nextcloud.

Available values:

    • auto

      default setting. keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed).

    • D, auto

      keeps files and folders in the trash bin for D+ days, delete anytime if space needed (note: files may not be deleted if space is not needed)

    • auto, D

      delete all files in the trash bin that are older than D days automatically, delete other files anytime if space needed

    • D1, D2

      keep files and folders in the trash bin for at least D1 days and delete when exceeds D2 days (note: files will not be deleted automatically if space is needed)

    • disabled

      trash bin auto clean disabled, files and folders will be kept forever

Defaults to auto

当然,我本来也想用nextcloud.occ直接配置,但想想可能会有奇怪的bug,还是直接修改php配置文件吧。自己找是不想找到,查询snap安装版本的Nextcloud的config/config.php的位置:

参考https://help.nextcloud.com/t/how-do-i-edit-the-config-php-file-on-a-nextcloud-box/12217/3中用户dev0的回答

dev0

May '17

Unfotunately that isn’t so easy in the ncbox as its installed with snap

i suggest you check the snap command on ssh

first do a snap list so you see which packages are installed

with snap refresh you can update your stuff but if you do that with nextcloud and the gap is too big, it will crash.

with snap info nextcloud you see the available commands:

  • nextcloud.disable-https
  • nextcloud.enable-https
  • nextcloud.manual-install
  • nextcloud.mysql-client
  • nextcloud.mysqldump
  • nextcloud.occ

i suggest you use the snap command to enable https because its better if its register that to the packet manager.

I have installed:

installed: 11.0.3snap1 (1288) 162MB -

so my config file which is applies should be this:

/var/snap/nextcloud/1288/nextcloud/config/config.php

there you can add the domain.

那好办,直接去我的/var/snap/nextcloud/current/nextcloud/config/config.php里修改就行。即添加'trashbin_retention_obligation' => 'auto,3',这一行,一般原来是没有这个配置的。


引用鸣谢:

  1. 神奇海域 » Nextcloud清理files_trashbin
  2. Nextcloud文档
  3. https://help.nextcloud.com/t/how-do-i-edit-the-config-php-file-on-a-nextcloud-box/12217/3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值