Script to empty trash

fixit7

Member
Joined
Mar 4, 2019
Messages
63
Reaction score
18
Credits
55
This script empties the Trash of any file except .deb files?

It is used in a crontab job to empty the trash every 15 minutes.

Anyone know why?

#!/bin/bash
find /home/andy/.local/share/Trash/expunged/ -type f -exec rm {} \;
find /home/andy/.local/share/Trash/files/ -type f -exec rm {} \;
find /home/andy/.local/share/Trash/info/ -type f -exec rm {} \;
find /media/andy/MAXTOR_SDB2/.Trash-1000/files/ -type f -exec rm {} \;
 


Strange! It removes .deb files for me!!

Could it be a permissions related thing?
What are the permissions on the .deb files that are persisting in those trash directories?

If the permissions aren’t the problem - you could also try using the -f flag in your rm commands, in order to force the .debs to be removed.

Also, have you tried using finds -delete option, instead of using -exec with rm?
e.g.
Bash:
find /path/to/search -type f -delete
 
When I tried it in Ubuntu Mate 20.04, it does delete .deb files.

Strange.
 
Strange! It removes .deb files for me!!

Could it be a permissions related thing?
What are the permissions on the .deb files that are persisting in those trash directories?

If the permissions aren’t the problem - you could also try using the -f flag in your rm commands, in order to force the .debs to be removed. From this payday loan affiliate program

Also, have you tried using finds -delete option, instead of using -exec with rm?
e.g.
Bash:
find /path/to/search -type f -delete


I have Ubuntu Mate 19.10, works fine
 
Last edited:

Members online


Latest posts

Top