Alwyn Mathew     Publication     Talks     Teaching     Blog     Resume

Auto emptying trash in Ubuntu

trash-cli trashes files recording the original path, deletion date, and permissions. It uses the same trashcan used by KDE, GNOME, and XFCE, but you can invoke it from the command line (and scripts). Install trash-cli with the below command:

sudo apt install trash-cli

Run trash-empty 30 to remove all files from trash which are older than 30 days (You can change this number as you like). To automate this, add a command to Startup Applications:

Ubuntu startup application

If you rarely restart your system, use cronjob. You can install cronjob with sudo apt install cron and edit/create your own crontab file with corntab -e and add the below

0 0 * * * trash-empty 30

Source: askubuntu