{ "version": "https://jsonfeed.org/version/1.1", "user_comment": "This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL -- https://matoken.org/blog/tag/autotrash/feed/json/ -- and add it your reader.", "home_page_url": "https://matoken.org/blog/tag/autotrash/", "feed_url": "https://matoken.org/blog/tag/autotrash/feed/json/", "language": "ja", "title": "autotrash – matoken's blog", "description": "Is there no plan B?", "icon": "https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9.jpeg", "items": [ { "id": "http://matoken.org/blog/?p=2110", "url": "https://matoken.org/blog/2018/09/14/the-trash-can-also-be-used-with-trash-cli-in-cli/", "title": "trash-cli \u3067 cli \u3067\u3082\u30b4\u30df\u7bb1\u5229\u7528", "content_html": "
rm \u30b3\u30de\u30f3\u30c9\u306f\u3068\u3066\u3082\u5f37\u529b\u3067\u3059\uff0e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3082\u306a\u304f\u8aa4\u3063\u3066\u524a\u9664\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u5fa9\u65e7\u3067\u304d\u306a\u3044\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3067\u3059\uff0e
\n\u305d\u3053\u3067 rm \u306e alias \u306b rm -i \u3092\u6307\u5b9a\u3057\u3066\u78ba\u8a8d\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u3059\u306a\u3069\u3057\u3066\u3044\u308b\u74b0\u5883\u3082\u3042\u308a\u307e\u3059\u304c\uff0c\u3044\u3064\u3082\u4f7f\u3063\u3066\u3044\u308b\u3068\u624b\u7656\u3067\u5373\u524a\u9664\u3057\u3066\u3057\u307e\u3063\u305f\u308a\u3057\u3066\u78ba\u5b9f\u3067\u306f\u3042\u308a\u307e\u305b\u3093\uff0eGUI\u74b0\u5883\u306e\u30d5\u30a1\u30a4\u30e9\u30fc\u306a\u3069\u3067\u306f\u30b4\u30df\u7bb1\u6a5f\u80fd\u304c\u4f7f\u3048\u3066\u524a\u9664\u3057\u3066\u3082\u30b4\u30df\u7bb1\u3092\u7a7a\u306b\u3059\u308b\u307e\u3067\u5fa9\u5143\u304c\u53ef\u80fd\u3067\u3059\uff0e
\n\u3053\u308c\u3092cui\u3067\u3082\u5229\u7528\u3067\u304d\u308b trash-cli \u3068\u3044\u3046\u30c4\u30fc\u30eb\u304c\u3042\u308a\u307e\u3059\uff0e\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u3068\u5171\u901a(freedesktop.org trashcan\u3068\u5171\u901a)\u306e\u30b4\u30df\u7bb1\u304c\u4f7f\u3048\u3066\u4fbf\u5229\u3067\u3059\uff0e
\u524a\u9664\u3057\u3066\u3057\u307e\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u5fa9\u5143\u3057\u305f\u3044\u5834\u5408\u306a\u308b\u3079\u304f\u65e9\u304f\u524a\u9664\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092 umount or mount -o ro \u3057\u3066\u30d5\u30a1\u30a4\u30eb\u5fa9\u5143\u30c4\u30fc\u30eb\u3092\u8a66\u3057\u3066\u307f\u308b\u3068\u3082\u3057\u304b\u3057\u305f\u3089\u5fa9\u5143\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff0eDebian \u306e\u5834\u5408 forensics-all/forensics-extra pkg \u7b49\u3092\u8997\u3044\u3066\u307f\u308b\u3068\u69d8\u3005\u306a\u30c4\u30fc\u30eb\u304c\u898b\u3064\u304b\u308b\u3068\u601d\u3044\u307e\u3059\uff0e(\u4f8b\u3048\u3070ext3/ext4\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u5fa9\u5143\u30c4\u30fc\u30eb\u306eextundelete\u3084\u6c4e\u7528\u306escalpel\u7b49)
\n$ sudo apt install trash-cli\r\n$ dpkg -L trash-cli|grep bin/\r\n/usr/bin/restore-trash\r\n/usr/bin/trash\r\n/usr/bin/trash-empty\r\n/usr/bin/trash-list\r\n/usr/bin/trash-put\r\n/usr/bin/trash-rm\n
$ touch hoge #\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\r\n$ trash hoge #\u30d5\u30a1\u30a4\u30eb\u3092\u6368\u3066\u308b\r\n$ mkdir -p hoge/fuga/piyo #\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4f5c\u6210\r\n$ trash hoge #\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6368\u3066\u308b\n
$ trash-list | grep hoge\r\n2018-09-11 05:36:19 /home/matoken/tmp/hoge\r\n2018-09-12 08:57:31 /home/matoken/tmp/hoge\r\n2018-09-12 08:37:09 /home/matoken/tmp/hoge\r\n2018-09-12 08:57:35 /home/matoken/tmp/hoge\r\n2018-09-12 08:36:56 /home/matoken/tmp/hoge\r\n2018-09-11 05:36:34 /home/matoken/tmp/hoge\n
$ trash-empty\r\n$ trash-list\n
$ restore-trash\r\n 0 2018-09-14 05:15:11 /home/matoken/tmp/piyo\r\n 1 2018-09-14 05:13:22 /home/matoken/tmp/hoge\r\n 2 2018-09-14 05:15:11 /home/matoken/tmp/fuga\r\nWhat file to restore [0..2]: 0 #\u5fa9\u5143\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u756a\u53f7\u3092\u6307\u5b9a\n
$ alias rm='trash'\r\n$ rm hoge\r\n$ rm -rf dir\n
\u3068\u3044\u3046\u611f\u3058\u3067\u7c21\u5358\u306b\u4f7f\u3048\u307e\u3059\uff0esudo \u3092\u4f7f\u3046\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\uff0e\u30b4\u30df\u7bb1\u306e\u5b9f\u4f53\u306f\u74b0\u5883\u306b\u3088\u308a\u307e\u3059\u304c\uff0c\u624b\u5143\u306e\u74b0\u5883\u3067\u306f ~/.local/share/Trash/ \u4ee5\u4e0b\u3067\u3057\u305f\uff0e\u3053\u306e\u3042\u305f\u308a\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u304c\u53c2\u8003\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\uff0e
\n\u30b4\u30df\u7bb1\u3092\u7a7a\u306b\u3057\u306a\u3044\u3068\u3069\u3093\u3069\u3093\u30d5\u30a1\u30a4\u30eb\u306f\u6e9c\u307e\u3063\u3066\u3044\u304d\u307e\u3059\uff0eautotrash \u3092\u4f7f\u3063\u3066\u6383\u9664\u3059\u308b\u306e\u304c\u304a\u3059\u3059\u3081\u3067\u3059\uff0e
\n\uff1c\u8ffd\u8a18\uff1e
\nGoogle+\u306e\u30b3\u30e1\u30f3\u30c8\u3067masaka\u3055\u3093\u306b\u6559\u3048\u3066\u3082\u3089\u3063\u305f\u306e\u3067\u3059\u304c\uff0ctrash-empty \u65e5\u4ed8 \u3068\u65e5\u4ed8\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u65e5\u4ed8\u4ee5\u4e0a\u306e\u65e5\u6570\u304c\u7d4c\u904e\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u304c\u524a\u9664\u3067\u304d\u308b\u3088\u3046\u3067\u3059\uff0e\u65e5\u4ed8\u6307\u5b9a\u3060\u3051\u306a\u3089autotrash \u3092\u5c0e\u5165\u3057\u306a\u304f\u3066\u3082\u3044\u3044\u3067\u3059\u306d\uff0e
\n\n\n\nMasakazu Takahashi
\n\n\n\u3061\u306a\u307f\u306btrash-cli\u3067\u3082`trash-empty 30`\u3068\u304b\u5b9f\u884c\u3059\u308b\u3068\u3001\u524a\u9664\u3057\u306630\u65e5\u8d85\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30b4\u30df\u7bb1\u304b\u3089\u6d88\u3057\u3066\u304f\u308c\u307e\u3059\u3002
\n
ARGUMENTS\r\n To remove all trashed files, use 'emtpy-trash'.\r\n\r\n To remove files that have been in the trash more than a given number of\r\n days, use 'trash-empty x', 'x' representing the number of days.\n
\uff1c\uff0f\u8ffd\u8a18\uff1e
\n$ dpkg-query -W trash-cli\r\ntrash-cli 0.12.9.14-2.1\r\n$ lsb_release -d\r\nDescription: Debian GNU/Linux unstable (sid)\r\n$ uname -m\r\nx86_64\n
\uff03trash-cli \u306f\u73fe\u5728 0.17.1.14 \u3067 0.12.9.14 \u306e\u30ea\u30ea\u30fc\u30b9\u65e5\u306f 15 Sep 2012 \u3068\u306a\u3063\u3066\u3044\u308b\uff0e
\n\u30b4\u30df\u7bb1\u306f\u4fbf\u5229\u3067\u3059\u304c\u3069\u3093\u3069\u3093\u6e9c\u307e\u3063\u3066\u3044\u304f\u306e\u3067\u5b9a\u671f\u7684\u306b\u6368\u3066\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\uff0e\u6c17\u304c\u5411\u3044\u305f\u3068\u304d\u306b\u30b4\u30df\u7bb1\u3092\u7a7a\u306b\u3059\u308b\u306e\u3067\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u305d\u308c\u3060\u30681\u6708\u524d\u306b\u30b4\u30df\u7bb1\u306b\u5165\u308c\u3066\u78ba\u5b9f\u306b\u30b4\u30df\u3067\u3042\u308d\u3046\u30d5\u30a1\u30a4\u30eb\u3082\u3055\u3063\u304d\u30b4\u30df\u7bb1\u306b\u5165\u308c\u305f\u3082\u3057\u304b\u3057\u305f\u3089\u8aa4\u3063\u3066\u524a\u9664\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3082\u4e00\u7dd2\u306b\u6d88\u3059\u3053\u3068\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u5fc3\u914d\u3067\u3059\uff0e
\nautotrash\u3092\u4f7f\u3046\u3068\u30b4\u30df\u7bb1\u306b\u5165\u308c\u305f\u65e5\u6570\u3084\u30d5\u30a1\u30a4\u30eb\u540d\uff0c\u7a7a\u304d\u5bb9\u91cf\u304c\u4f55GB\u3088\u308a\u5c11\u306a\u304f\u306a\u3063\u305f\u306a\u3069\u306e\u69d8\u3005\u306a\u6761\u4ef6\u306b\u3088\u308a\u30b4\u30df\u7bb1\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff0ecrontab\u306b\u767b\u9332\u3057\u3066\u304a\u304f\u3068\u81ea\u52d5\u5316\u3082\u3067\u304d\u3066\u304a\u85a6\u3081\u3067\u3059\uff0e
\u203b\u4ee5\u4e0b\u306fman\u306eexample\u3067\u65e5\u672c\u8a9e\u90e8\u5206\u306f\u9593\u9055\u3063\u3066\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093 –dry-run \u3068 –verbose \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u3066\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u305f\u4e0a\u3067\u4f7f\u3046\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\uff0e
\nautotrash -d 30\r\n Purge any file that has been in the trash for more then 30 days.\n
autotrash --max-free 1024 -d 30\r\n Only purge files from the trash if there is less than 1GB of space left on the trash filesystem. If so, only trash files that are older than 30 days.\n
autotrash --min-free 2048\r\n Purge files from trash, oldest first, till there is at least 2GB of space on the trash filesystem. There is no restriction on how old trashed files are.\n
autotrash --min-free 2048 -D '.*\\.bak' -D '.*\\.avi'\r\n Purge files from trash till there is at least 2GB of space on the trash filesystem. If we need to remove files, make sure we remove *.bak files first, then\r\n all *.avi files and after that the oldest to the newest. There is no restriction on how old trashed files can get. Please note that '.*\\.bak' and '.*\\.avi'\r\n are regular expressions and not glob patterns. Given that they are regular expressions, using -D '.*\\.(png|gif|jpg|jpeg)' will match images with any of the\r\n given extensions.\n
autotrash --max-free 4000 --min-free 2048 -d 30\r\n Start reading the trash if there is less than 4000MB of free space, then start keeping an eye on. At that point, remove files older than 30 days and if\r\n there is less than 2GB of free space after that remove even newer files.\n
\u79c1\u306f\u5358\u7d14\u306b\u30b4\u30df\u7bb1\u306b\u5165\u308c\u306633\u65e5\u7d4c\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\uff0e
\n\u3053\u306e\u4f8b\u3067\u306f\u6bce\u65e502:08\u306b\u512a\u5148\u5ea6\u3092\u4e0b\u3052\u3066\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\uff0evixie-cron\u306e\u5834\u5408\u3000@daily \u3067\u3082\u3044\u3044\u3057\uff0c @reboot \u3067\u30b7\u30b9\u30c6\u30e0\u8d77\u52d5\u6642\u306b\u51e6\u7406\u3068\u304b\u3067\u3082\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff0e\u8a73\u7d30\u306f man 5 crontab \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\uff0e
$ crontab -l|grep autotrash\r\n8 2 * * * nice -n 19 ionice -c 3 autotrash -d 33\n
\u305f\u3060\uff0c\u3053\u308c\u306f\u30b4\u30df\u7bb1\u3092\u4f7f\u3063\u3066\u3044\u308b\u30e6\u30fc\u30b6\u6bce\u306b\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u304c\u3061\u3087\u3063\u3068\u9762\u5012\u3067\u3059\uff0e\u4e00\u4eba\u3067\u4f7f\u3063\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u306a\u3089\u3044\u3044\u306e\u3067\u3059\u304c\uff0c\u5229\u7528\u8005\u304c1000\u4eba\u3060\u3068 /etc/crontab \u306b1000\u884c\u66f8\u304f\u306a\u3069\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\uff0e
\nautotrash 0.2.1 \u3067\u306f -t \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u5168\u30e6\u30fc\u30b6\u306e\u30c1\u30a7\u30c3\u30af\u304c\u51fa\u6765\u308b\u3088\u3046\u3067\u3059\uff0e(\u624b\u5143\u306e\u74b0\u5883\u3067\u306f 0.1.5 \u306a\u306e\u3067\u672a\u78ba\u8a8d)
You can also make autotrash process all user trash directories (not just in your home directory) by adding this crontab entry:\r\n\r\n@daily /usr/bin/autotrash -td 30\n
$ dpkg-query -W autotrash\r\nautotrash 0.1.5-1.1\r\n$ lsb_release -d\r\nDescription: Debian GNU/Linux unstable (sid)\r\n$ uname -m\r\nx86_64\n
\uff03sid\u3060\u3051\u3069upstream\u306b\u8ffd\u5f93\u3057\u3066\u306a\u3044\u3067\u3059\u306d><
\n