AUTOTRASH(1)

๐Ÿ“ฆ version 0.4.7, in nixos 26.05, nixpkgs unstable

๐ŸŒธ AUTOTRASH(1) โ€” or, how to make your trash can stop hoarding ๐Ÿ’…

okay so first things first bestie: this is autotrash, from the General Commands Manual (section 1, the classics โœจ), and it's about to become your new favorite little cleanup gremlin. let's go ๐Ÿงš


โœจ NAME โœจ

autotrash โ€” a program to automatically purge old files from the FreeDesktop.org trash ๐Ÿ—‘๏ธ๐Ÿ’–

like literally it goes into your trash and evicts the old stuff so you don't have to. no cap.


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

autotrash [-d purge_n_days_old]

autotrash [โ€“delete number_of_megabytes_to_purge]

autotrash [โ€“keep-free number_of_megabytes_to_free]

three moods, three shapes of invocation. pick your fighter ๐Ÿ’…


๐ŸŒธ DESCRIPTION ๐ŸŒธ

So autotrash is a program that looks in a FreeDesktop.org Trash folder for info on what's inside it, and then purges a part of the trash depending on which options you gave it. That's the whole vibe.

The most common option is -d, which purges files that have been sitting in the trash for more than a given number of days. bye girl ๐Ÿ‘‹

The option โ€“delete will remove at least the given number of megabytes from the trash, and it removes the oldest trash first. oldest-first, always. respect the queue ๐Ÿซถ

Using โ€“keep-free makes 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 1GB of free space โ€” removing files from the trash if needed โ€” you'd run autotrash โ€“keep-free 1024. iconic. it does the math so you don't have to ๐Ÿงฎโœจ


๐Ÿ’… OPTIONS ๐Ÿ’…

This program follows the usual GNU command line syntax, with long options starting with two dashes (-). classic, we love a consistent king ๐Ÿ‘‘

  • -h, โ€“help โ€” shows a summary of options. your little map ๐Ÿ—บ๏ธ
  • -d DAYS, โ€“days DAYS โ€” purges files older than DAYS number of days. the og move ๐Ÿ’ซ
  • -T PATH, โ€“trash-path PATH โ€” use the given path as the location of the Trash directory instead of the default: ~/.local/share/Trash. yes you can point it somewhere else, she's flexible ๐ŸŽ€
  • โ€“max-free M โ€” only purges files if there's less than M megabytes of free space left at the trash location. so like, if you set this to 1024, then autotrash will only start to work if there's less than 1GB of free space in the trash. until that time, autotrash will just exit normally without scanning the Trash directory at all โ€” she peeks, she leaves, no drama ๐Ÿ™ˆ. if unsure, try running autotrash with โ€“dry-run and โ€“verbose to see the effect ๐Ÿ‘€
  • โ€“delete M โ€” purges at least M megabytes, deleting oldest trash addition first. important: it uses trash entries, NOT individual files โš ๏ธ. this means that if your oldest trashed item is a 1GB directory and you request at least 10MB to be removed (M=10), autotrash will remove 1GB. yeah. the whole 1GB. it's giving all-or-nothing ๐Ÿ’€. if unsure, try running autotrash with both โ€“dry-run and โ€“stat to see the effect.
  • โ€“min-free M, โ€“keep-free M โ€” makes sure there's a minimum of M megabytes of free space. if there's less free space, it sets โ€“delete to the difference between M and the amount of free space. if unsure, try running autotrash with โ€“dry-run and โ€“verbose to see the effect ๐Ÿ’–
  • โ€“trash_limit M โ€” makes sure the trash doesn't consume more than M megabytes. if more space is consumed, it sets โ€“delete to the difference between M and the amount of space consumed by the trash. a literal cap on the hoard ๐Ÿ”ฅ
  • -D REGEX, โ€“delete-first REGEX โ€” purges any file which matches REGEX first, regardless of its timestamp. REGEX must be a valid regular expression. if this option is used multiple times, the files matching the first regular expression are deleted first, then the second, etc. priority list, main character energy ๐Ÿ‘‘ Example: delete any .avi files first, then by age: โ€“delete-first .*.avi'`
  • -v, โ€“verbose โ€” outputs information on what's happening and why. she narrates ๐Ÿ—ฃ๏ธโœจ
  • -q, โ€“quiet โ€” only outputs warnings. minimalist era ๐Ÿคซ
  • โ€“check โ€” reports .trashinfo files that point to a non-existing file. this will only happen with a broken Trashcan ๐Ÿ˜ญ. it's left up to you, the user, to actually do something with this information. these files will be removed as soon as the mentioned file would be removed by autotrash.
  • โ€“dry-run โ€” only lists what would be done, but actually does nothing. dress rehearsal ๐ŸŽญ
  • โ€“stat โ€” shows the number and total size of files involved. receipts ๐Ÿ“Š
  • -V, โ€“version โ€” shows the version of the program. say hi ๐Ÿ‘‹
๐Ÿšจ The exit status of autotrash will be 1 if a corrupt trashinfo file is found. that's your signal something's weird, bestie, don't ignore it.

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

Examples of program use. come get your demo, this is the fun part ๐Ÿ“

  • autotrash -d 30 โ€” purge any file that has been in the trash for more than 30 days. clean, simple, effective โœจ
  • autotrash โ€“max-free 1024 -d 30 โ€” only purge files from the trash if there's less than 1GB of space left on the trash filesystem. if so, only trash files that are older than 30 days. conditional queen ๐Ÿ‘‘
  • autotrash โ€“min-free 2048 โ€” purge files from trash, oldest first, till there's at least 2GB of space on the trash filesystem. there's no restriction on how old trashed files are. age is just a number ๐Ÿ’ซ
  • autotrash โ€“min-free 2048 -D .\.bak' -D .*\\.avi' โ€” purge files from trash till there's at least 2GB of space on the trash filesystem. if we need to remove files, make sure we remove .bak files first, then all .avi files, and after that the oldest to the newest. there's no restriction on how old trashed files can get. please note that .*\.bak and .*\.avi are regular expressions and not glob patterns ๐Ÿง . given that they're regular expressions, using -D ..(png|gif|jpg|jpeg)'` will match images with any of the given extensions. regex girlies rise ๐Ÿ”ฅ
  • autotrash โ€“max-free 4000 โ€“min-free 2048 -d 30 โ€” start reading the trash if there's less than 4000MB of free space, then start keeping an eye on it. at that point, remove files older than 30 days, and if there's less than 2GB of free space after that, remove even newer files. escalation arc ๐Ÿ“ˆ
  • autotrash โ€“trash_limit 200 -d 30 โ€” remove files older than 30 days. if the trash consumes more than 200MB, remove even newer files. boundaries. set them ๐Ÿ’…
  • @hourly /usr/bin/autotrash โ€“max-free 4000 โ€“min-free 2048 -d 30 โ€” experienced users should consider adding autotrash as a crontab entry, using crontab -e and adding the line above. set it and forget it, the highest form of self care ๐Ÿง˜โ€โ™€๏ธ

๐ŸŽ€ COPYING ๐ŸŽ€

Copyright ยฉ 2015 Bram Neijt bneijt@gmail.com

This manual page was written for the Debian system (and may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 or any later version published by the Free Software Foundation. ๐Ÿ“œ

On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. there ya go, all the legal lore ๐Ÿซถ


โญ AUTHORS โญ

A. Bram Neijt bneijt@gmail.com


and that's the whole page bestie ๐Ÿ’– this was AUTOTRASH(1) from the General Commands Manual, section 1, and it's filed under AUTOTRASH(1) on the way out too โ€” same name, same page, no version bump, no date drama, just good clean trash-purging documentation. go forth and empty responsibly ๐ŸŒธ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from