06_remove_too_many_files.sh 837 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # Needs jq package installed
  3. sudo -u apache php occ user:list > /tmp/list_user_06.txt
  4. while read line; do
  5. echo "$line"
  6. uid=`echo "${line:2}" | cut -d":" -f1`
  7. #echo "$uid"
  8. info_user=`sudo -u apache php occ user:info "$uid" --output=json`
  9. #echo $info_user
  10. homePath=`echo $info_user | jq -r '.user_directory'`
  11. #echo $homePath
  12. if [ -d $homePath ]; then
  13. du_homePath=`du -s $homePath | cut -f 1`
  14. wc_homePath=`find $homePath -type f | wc -l`
  15. else
  16. continue
  17. fi
  18. if (( $wc_homePath > 30000 )); then
  19. if [ $homePath != "/data/pbarriat" ]; then
  20. echo "Remove files $homePath/files/* for user $uid"
  21. #rm -rf $homePath
  22. #sudo -u apache php occ files:scan -vvv $uid --home-only
  23. fi
  24. fi
  25. #exit
  26. done < /tmp/list_user_06.txt
  27. #sudo -u apache php occ files:scan -vvv --all --home-only