Date: Wed, 15 Nov 2006 00:53:51 +1100 (EST) From: Ian Smith <smithi@nimnet.asn.au> To: Koen de Wijs <koendewijs@gmx.net> Cc: freebsd-questions@freebsd.org Subject: deleting automatically the oldest file from a harddisk Message-ID: <Pine.BSF.3.96.1061115000552.20532A-100000@gaia.nimnet.asn.au> In-Reply-To: <20061113200345.B476516A4F5@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 13 Nov 2006 Koen de Wijs wrote: > I have a ftp -server. I use a harddisk of 9 Gb for the ftp-directory. > > This isn't very big so I want to throw away the oldest file if the disc > is full. I'd tend to define 'full' as perhaps 8GB in that situation, and likely protect at least some ftp directories from purely date-based purging. > I can write a cronjob that checks every minute. But isn't there another > solution; If you leave enough headroom then hourly might be often enough? > Can't I just write a C program that listens to some systemcalls and > automatically deletes the oldest file if the harddisk is full??? Well you can do anything in C if you know how and have the time :) but a small script using existing utilities would be a lot easier. Sounds like a job for find(1) to me. Search for the numerous primaries matching 'time' or 'newer', also see -size and maybe others useful for generating a list of pathnames of your candidate(s) to feed to rm(1) Cheers, Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.1061115000552.20532A-100000>