limit folder size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ikbel borcheni
    New Member
    • Mar 2011
    • 24

    limit folder size

    Hi,I would like to limit a folder space (in a shell script):
    when the folder exceeds the maximum size, I have to remove the oldest files
    How to do this and how to make it running all the time?

    thanks for the help
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    I would create a script that ran a 'du -hs /path/to/folder' to check the size. Then you could use sed or awk to get the list of the contents of that folder - including date (or pipe ls -alh or something into it), and remove the 'biggest'.

    That script would then go into cron and be set for how often you'd like it to run.

    Comment

    Working...