Line 41: |
Line 41: |
| | | |
| /home/e-smith/files/users/username/home/Recycle Bin | | /home/e-smith/files/users/username/home/Recycle Bin |
| + | |
| + | === Automatic Cleaning Of Recycle Bin Content === |
| + | |
| + | The simple script below can be used to clean out the various Recycle Bins on a regular basis. Note that this script is setup to use the last accessed file attribute to selectively deletes files after they have been in the Recycle Bin for 30 days. |
| + | |
| + | Setup the script to run either daily or weekly from cron. |
| + | |
| + | <pre> |
| + | #!/bin/bash |
| + | |
| + | echo "+------------------------------------------------------------------------------+" |
| + | echo "| Samba recycle-bin cleaner |" |
| + | echo "+------------------------------------------------------------------------------+" |
| + | |
| + | URF=$(find /home/e-smith/files/users/*/home/Recycle\ Bin/* -type f -atime +30) |
| + | if [ "$URF" != "" ] |
| + | then |
| + | printf "| %-76s |\n" "The following user recycle bin files were deleted:" |
| + | IFS=$'\n' |
| + | for file in $URF |
| + | do |
| + | printf "| - %-74s |\n" "$file" |
| + | rm -f "$file" |
| + | done |
| + | else |
| + | printf "| %-76s |\n" "There were no old user recycle bin files to delete." |
| + | fi |
| + | |
| + | echo "+------------------------------------------------------------------------------+" |
| + | |
| + | IRF=$(find /home/e-smith/files/ibays/*/files/Recycle\ Bin/* -type f -atime +30) |
| + | if [ "$IRF" != "" ] |
| + | then |
| + | printf "| %-76s |\n" "The following ibays recycle bin files were deleted:" |
| + | IFS=$'\n' |
| + | for file in $IRF |
| + | do |
| + | printf "| - %-74s |\n" "$file" |
| + | rm -f "$file" |
| + | done |
| + | else |
| + | printf "| %-76s |\n" "There were no old ibays recycle bin files to delete." |
| + | fi |
| + | |
| + | echo "+------------------------------------------------------------------------------+" |
| + | |
| + | URD=$(find /home/e-smith/files/users/*/home/Recycle\ Bin/* -type d -empty) |
| + | if [ "$URD" != "" ] |
| + | then |
| + | printf "| %-76s |\n" "The following users recycle bin directories were deleted:" |
| + | IFS=$'\n' |
| + | for folder in $URD |
| + | do |
| + | printf "| - %-74s |\n" "$folder" |
| + | rm -rf "$folder" |
| + | done |
| + | else |
| + | printf "| %-76s |\n" "There were no old user recycle bin directories to delete." |
| + | fi |
| + | |
| + | echo "+------------------------------------------------------------------------------+" |
| + | |
| + | IRD=$(find /home/e-smith/files/ibays/*/files/Recycle\ Bin/* -type d -empty) |
| + | if [ "$IRD" != "" ] |
| + | then |
| + | printf "| %-76s |\n" "The following ibays recycle bin directories were deleted:" |
| + | IFS=$'\n' |
| + | for folder in $IRD |
| + | do |
| + | printf "| - %-74s |\n" "$folder" |
| + | rm -rf "$folder" |
| + | done |
| + | else |
| + | printf "| %-76s |\n" "There were no old ibays recycle bin directories to delete." |
| + | fi |
| + | |
| + | echo "+------------------------------------------------------------------------------+" |
| + | </pre> |
| | | |
| === Changing the Recycle Bin name === | | === Changing the Recycle Bin name === |