如何设置Ubuntu 16.04 LTS以根据参数自动清空垃圾箱?
有一种方法可以为特定用户定期盲目清空Ubuntu 16.04 LTS系统上的垃圾。
从包含以下行的脚本开始:
#!/bin/bash rm -rf ~/.local/share/Trash/*
然后使用cron让它定期运行。
(事实上,这也适用于Raspbian和其他版本的Debian,也)
但是,如果将文件保存xx天,或者直到可用空间低于yy或其他参数,那会怎样?
问题出在标题中:如何设置Ubuntu 16.04以根据参数自动清空垃圾箱?
事实certificate,有一个名为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
该手册页继续描述许多其他选项。