Autotrash tool for Linux to automatically delete old junk files at a scheduled time

Autotrash tool for Linux to automatically delete old junk files at a scheduled time

Autotrash is a command line program that automates the process of cleaning out old deleted files. It will clear files in the Recycle Bin that are older than the specified number of days. You don't need to empty the Recycle Bin or perform SHIFT+DELETE to permanently clear files/folders. Autortrash will process the contents of your Recycle Bin and automatically delete them after a certain period of time. In short, your trash will never get too big with Autotrash.

Install Autotrash

Autotrash is included by default in the repository on Debian based systems. To install autotrash on Debian, Ubuntu, Linux Mint, run:

$ sudo apt-get install autotrash

On Fedora:

$ sudo dnf install autotrash

For Arch linux and its variants, you can install it using any AUR helper program like Yay.

$ yay -S autotrash-git

Automatically clean up old junk files

Whenever you run autotrash, it scans your ~/.local/share/Trash/info directory and reads the .trashinfo files to find out their deletion dates. If files have been in the Recycle Bin for longer than the specified date, they are deleted.

Let me give you some examples

To delete files in the Recycle Bin that are older than 30 days, run:

$ autotrash -d 30

As shown in the example above, Autotrash automatically deletes files from the Recycle Bin if they are older than 30 days. You don't need to delete them manually. Just put useless files in the Recycle Bin and forget about them. Autotrash will take care of deleted files.

The above command processes the trash directory of the currently logged in user only. If you want autotrash to process all users' trash directories (not just those in your home directory), use the -t option, as shown below:

$ autotrash -td 30

Autotrash also allows you to remove deleted files based on the available capacity of the Recycle Bin or the available space on the disk.

For example, consider the following example:

$ autotrash --max-free 1024 -d 30

According to the above command, if the remaining space in the Recycle Bin is less than 1GB, autotrash will clear deleted files older than 30 days from the Recycle Bin. This may be useful if your Recycle Bin is running low on space.

We can also clear files from the Recycle Bin by oldest time until the Recycle Bin has at least 1GB of space.

$ autotrash --min-free 1024

In this case, there is no restriction on old deleted files.

You can combine these two options (--min-free and --max-free) in one command as follows

$ autotrash --max-free 2048 --min-free 1024 -d 30

According to the above command, if the free space is less than 2GB, autotrash will read the Recycle Bin and then focus on the capacity. At this time, files older than 30 days are deleted, and if there is less than 1GB of free space, newer files are deleted.

As you can see, all commands should be run manually by the user. You might be wondering, how can I automate this task? It's easy! Just add autotrash as a crontab task. Now the command will run automatically at the scheduled time and clear the files in the Recycle Bin according to the defined options.

To add these commands to your crontab, run:

$ crontab -e

Add tasks, for example:

@daily /usr/bin/autotrash -d 30

Now, autotrash will purge files in the recycle bin every day that are older than 30 days.

Please note that if you accidentally delete any important files, they will be gone forever after the specified date, so be careful.

See the man page for more information about Autotrash.

$ man autotrash

Empty the Recycle Bin or press SHIFT+DELETE to permanently delete useless things from your Linux system. It's no big deal. It only takes a few seconds. However, if you need an additional program to deal with junk files, Autotrash might be able to help. Try it and see how it works.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Five Linux server distributions worth choosing in 2018
  • How to Choose a Linux Distribution in 2016
  • How to achieve coexistence of different Linux operating system distributions
  • Basic knowledge of Linux distributions and installation
  • Use iptables and firewalld tools to manage Linux firewall connection rules
  • Detailed explanation of Linux server status and performance related commands
  • How to Run a Command at a Specific Time in Linux
  • Installation of python2.7.10 under Linux system (CentOS)
  • Python 3.6.1 environment configuration tutorial under Linux
  • Linux uses NetworkManager to randomly generate your MAC address
  • An audio-visual Linux distribution that appeals to audiophiles

<<:  Manually install mysql5.7.10 on Ubuntu

>>:  js implements mouse switching pictures (without timer)

Blog    

Recommend

How to reset the root password in CentOS7

There are various environmental and configuration...

Use CSS to switch between dark mode and bright mode

In the fifth issue of Web Skills, a technical sol...

Implementation of multi-site configuration of Nginx on Mac M1

Note: nginx installed via brew Website root direc...

A brief discussion on MySQL index optimization analysis

Why are the SQL queries you write slow? Why do th...

Book page turning effects made with CSS3

Result:Implementation code: html <!-- Please h...

js implements a simple calculator

Use native js to implement a simple calculator (w...

Web Design TabIndex Element

TabIndex is to press the Tab key to sequentially o...

An article explains Tomcat's class loading mechanism

Table of contents - Preface - - JVM Class Loader ...

When to use table and when to use CSS (experience sharing)

The main text page of TW used to have a width of 8...

VUE implements timeline playback component

This article example shares the specific code of ...

MySQL 5.7.23 installation and configuration method graphic tutorial

This article records the installation tutorial of...

Vue-pdf implements online preview of PDF files

Preface In most projects, you will encounter onli...

MySQL data loss troubleshooting case

Table of contents Preface On-site investigation C...