Sponsored Link
Features:
Remove files that are older then a given number of days (see the -d option)
Purge older files to ensure a specific amount of disk space is free (see the --min-free option)
Check for remaining disk space, and only delete if you are running out (see the --max-free option)
Delete regex matching files first (see --delete-frist option)
Install autotrash on ubuntu
Open the terminal and run the following command
sudo apt-get install autotrash
Syntax
autotrash [-d purge_n_days_old]
autotrash [--delete number_of_megabytes_to_purge]
autotrash [--keep-free number_of_megabytes_to_free]
Autotrash Examples
Purge any file that has been in the trash for more then 30 days.
autotrash -d 30
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.
autotrash --max-free 1024 -d 30
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.
autotrash --min-free 2048
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 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' 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 given extensions.
autotrash --min-free 2048 -D ‘.*\.bak' -D ‘.*\.avi'
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 there is less than 2GB of free space after that remove even newer files.
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.
@hourly /usr/bin/autotrash --max-free 4000 --min-free 2048 -d 30
I have this running as a startup application with 1 day set. Is there any way to make it run and delete at startup regardless of the length of time? So, just when I startup, it’ll delete whatever is in the trash?