Differences
This shows you the differences between two versions of the page.
— |
cpanel-clean-trash [2019-03-14 18:22:47] (current) shaun.reitan created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== How to empty all cPanel File Manager .trash bins ====== | ||
+ | |||
+ | When deleting files using cPanel' | ||
+ | |||
+ | The following script was created to clean out these trash bins when when files have existed in them for more than 30 days | ||
+ | |||
+ | <code console> | ||
+ | #!/bin/bash | ||
+ | |||
+ | getent=$(getent passwd) | ||
+ | if [ $? -ne 0 ]; then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | getent passwd | while IFS=: read -r user_name user_pw user_id user_gid user_comments user_homedir user_shell; do | ||
+ | if [ ${user_id} -lt 500 ]; then | ||
+ | echo " | ||
+ | continue | ||
+ | fi | ||
+ | |||
+ | if [ ! -d " | ||
+ | echo " | ||
+ | continue | ||
+ | fi | ||
+ | |||
+ | echo " | ||
+ | su ${user_name} -s /bin/bash -c 'find ~/.trash/ -mtime +30 -type f -exec rm -vf {} \;' | ||
+ | su ${user_name} -s /bin/bash -c 'find ~/.trash/ -mtime +30 -type d -empty -delete' | ||
+ | echo "Done Cleaning ${user_homedir}/ | ||
+ | done | ||
+ | </ | ||