daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Mar 20th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top