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