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)

Recommend

Useful codes for web page creation

<br />How can I remove the scroll bar on the...

Docker learning method steps to build ActiveMQ message service

Preface ActiveMQ is the most popular and powerful...

Detailed explanation of the concept, principle and usage of MySQL triggers

This article uses examples to explain the concept...

Vue's guide to pitfalls using throttling functions

Preface In a common business scenario, we need to...

Form submission page refresh does not jump

1. Design source code Copy code The code is as fol...

How to prevent Flash from covering HTML div elements

Today when I was writing a flash advertising code,...

Various types of MySQL indexes

What is an index? An index is a data structure th...

Vue implements a simple timer component

When doing a project, it is inevitable to encount...

Detailed steps for using AES.js in Vue

Use of AES encryption Data transmission encryptio...

Implementation and usage scenarios of JS anti-shake throttling function

Table of contents 1. What is Function Anti-shake?...

Pure CSS to achieve left and right drag to change the layout size

Utilize the browser's non- overflow:auto elem...

Detailed explanation of map overlay in openlayers6

1. Overlay Overview Overlay means covering, as th...

An elegant way to handle WeChat applet authorization login

Preface When the WeChat mini program project invo...

Detailed explanation of Vue filters

<body> <div id="root"> <...

Web designer is a suitable talent

<br />There is no road in the world. When mo...