Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. DIR=/tmp
  4. CAPACITY_LIMIT=90
  5. CAPACITY=$(df -k . | awk '{gsub("%",""); capacity=$5}; END {print capacity}')
  6.  
  7. # Delete oldest files until we're under limit
  8. while [ $CAPACITY -gt $CAPACITY_LIMIT ] ; do
  9. find $DIR -type f -printf "%T@ %p\n" | sort -nr | tail -1 | cut -d' ' -f 2- | xargs -d '\n' rm
  10. # Delete empty dirs
  11. find $DIR -type d -empty -delete
  12. CAPACITY=$(df -k . | awk '{gsub("%",""); capacity=$5}; END {print capacity}')
  13. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement