3 ms·
I have certainly written code which consists of "while (free disk space is less than X) {, delete oldest log file}". Such code would break on zfs. Is there ev
by londons_explore 4y ago
I have certainly written code which consists of "while (free disk space is less than X) {, delete oldest log file}".
Such code would break on zfs.
Is there even a better way to achieve "I want all spare space to be filled with logfiles, but I never want to run out of space."?
- deleted 4y ago[deleted]
- londons_explore 4y agoOne could imagine an "opportunistic storage" flag on a file which means 'consider this file deletable if you ever need the space'. It would be especially good for caches of remote files or data that could be recalculated on demand. We already have lots of similar things for RAM - for example Javas SoftReference.
- puffoflogic 4y agoYou can do the math yourself every loop instead of asking the OS. Ask how much free space is available once at the start, track how big each file is, delete. You can sleep and check free space again at the end as a sanity check; if the free space isn't going down nearly as much as you expected report it to the user and inhibit future script executions b/c it means there's something referencing extents and your script is about to go on a rampage.
- lathiat 4y agoIt also would be broken by having snapshots, since, the space wouldn't actually be freed, so this space accounting is not the only possible issue.