Note that if you're getting an error about "no such directory," it's likely because the. Before running this for the first time, I would also recommend opening up ssh and running the command without the -delete flag the output should be a list of files that meet the criteria for deletion and looking over these now could save you a ton of snapshot rollbacks later. Both will work, but having a script going around running rm -rf makes me a little uneasy, so I prefer not to do it. You may also note that instead of running rm -rf everywhere, I'm using the -delete flag. The threshold is determined by the atime flag and can be changed to your desires. recycle anywhere in the "tank" dataset regardless of share and delete everything in it older than 30 days. :)Ĭode: find /mnt/tank/*/.recycle/* -atime 30 -delete Yes, I'm a little OCD about my files being organized and not letting stray orphans collect on my servers. ![]() ![]() recycle folder itself that would also be helpful. Additionally, if there was a way to delete an empty. I'm sure many other people that like to set-it-and-forget-it would love a script that seeks out the. recycle and then apply the following commands that would be very cool and very helpful for myself. If someone has an idea for how to modify the script to actually seek out folders that are named. You will need to be proactive with adding these lines for each share you ever create, else your recycle bin for that share will only continue to grow. If you delete something from the Documents share, it will end up in /mnt/tank/Documents/.recycle. If you delete something from the Stuff share, it will end up in /mnt/tank/Stuff/.recycle. If you delete something from the Music share, it will end up in /mnt/tank/Music/.recycle. If you delete something from the Movies share, it will end up in /mnt/tank/Movies/.recycle. Lets say you have the following locations with the following shares: I'm guessing someone actually has the solution as I don't (but I'm looking for it and I'll post back when I have a working script). That’s all! Do you know of any similar CLI tools for Linux? Share some info about them with us via the comment form below.I hate people that necro threads, but I feel I should point this out. Here is a demonstration of this command: $ dateĭo not forget to use quotes in order to protect the pattern from shell expansion: $ trash-rm \*.txtįor more information, check out Trash-cli Github repository: Remove only the files that have been deleted more than ago: $ trash-empty $ sudo yum install python-setuptools #RHEL/CentOS systemsĮlse, install Trash-cli from source as shown. The straightforward way of installing trash-cli is by using easy_install tool as follows: $ sudo apt-get install python-setuptools #Debian/Ubuntu systems ![]() ![]() In this article, we will show you how to install and use trash-cli to find the original path, deletion date, and permissions of deleted files in Linux. $ trash-rm #remove individual files from the trashcan. Trash-cli provides these commands: $ trash-put #trash files and directories. It uses the same trashcan used by popular Linux desktop environments such as KDE, GNOME, and XFCE which can be invoked from the command line (and via scripts). Trash-cli is a command line interface that trashes files and records the original absolute path, deletion date, and associated permissions.
0 Comments
Leave a Reply. |