AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 940917
Accepted
SDsolar
SDsolar
Asked: 2017-07-30 00:08:09 +0800 CST2017-07-30 00:08:09 +0800 CST 2017-07-30 00:08:09 +0800 CST

如何设置 Ubuntu 16.04 LTS 以根据参数自动清空垃圾箱?

  • 772

有一种方法可以在 Ubuntu 16.04 LTS 系统上为特定用户定期盲目清空垃圾箱。

从包含以下行的脚本开始:

#!/bin/bash
rm -rf ~/.local/share/Trash/*

然后使用 cron 让它定期运行。

(事实上​​,这也适用于 Raspbian 和其他版本的 Debian)


但是,如果最好将文件保留 xx 天,或者直到可用空间低于 yy 或其他一些参数,该怎么办?

问题就在标题中:如何设置Ubuntu 16.04根据参数自动清空垃圾箱?

16.04
  • 1 1 个回答
  • 795 Views

1 个回答

  • Voted
  1. Best Answer
    SDsolar
    2017-07-30T00:08:09+08:002017-07-30T00:08:09+08:00

    原来有一个名为 autotrash 的程序可以在 Ubuntu 16.04 LTS 下运行。

    这是一篇描述其工作原理的文章:

    在 Ubuntu 中自动清空垃圾箱

    --> 本文内容丰富但较旧,因此请不要按照安装说明进行操作。

    相反,只需这样做:

    sudo apt-get update
    sudo apt-get install autotrash
    

    然后通过输入带参数的 autotrash 命令执行程序。

    这可以由 cron 定期运行,并基于特定参数:

    这些论点在

    Ubuntu 16.04 LTS 的 autotrash 手册页

    摘抄:

    NAME autotrash — 自动从垃圾箱中清除旧文件的程序

    概要 autotrash [-d purge_n_days_old]

       autotrash [--delete number_of_megabytes_to_purge]
    
       autotrash [--keep-free number_of_megabytes_to_free]
    

    描述 autotrash 是一个程序,它在 FreeDesktop.org Trash 文件夹中查找有关其内容的信息,然后根据选项清除一部分垃圾。

       The most common option is -d, which will purge files that have been  in
       the trash for more then a given number of days.
    
       The  option --delete will remove at least the given number of megabytes
       from the trash, removing the oldest trash first.
    
       Using --keep-free will make sure at least the given number of megabytes
       of  free  space  is available, by automatically setting --delete to the
       right value. For example, to  keep  at  least  a  1GB  of  free  space,
       removing files from the trash if needed, use autotrash --keep-free 1024
    

    手册页继续描述许多其他选项。

    • 3

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve