DOL – Delete Oldest Logs

This is a little program I made some time ago because I had some problems with some log files I generated. I didn’t know how big they would end up and I had a limited disk space. As you can guess, it can be used for any files. So I could have called it “DOF – Delete Oldest Files”.

The idea of this tiny .Net program is to delete the oldest logs first. It scans every files and delete as many files as required to reach its objectives.

Command line arguments (-h option) :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
DOL - Delete Oldest Logs (first)
Arguments are :
===============
-d          : Directory where to analyse files
-dr         : Directory where to analyse files recursively
-de         : Delete empty dirs
-sm         : Sort files by modification (default)
-sc         : Sort files by creation
-sa         : Sort files by access
-ds <size>  : Delete oldest logs to reach a total size of <size> (in bytes)
-dn <nb>    : Delete oldest logs to reach a total number of <nb>
-v          : Switch to verbose mode
 
Numbers can have k,m,g :
1k = 1 024         bytes
1m = 1 048 576     bytes
1g = 1 073 741 824 bytes

So, on Windows, you will probably do somethind like :

1
dol.exe -de -dr C:\temp -ds 2g

On Linux, it’s the same thing with a “mono” before.

1
mono dol.exe -dr /var/log/apache -ds 1g

You can download it here (13.5 KB).

Leave a Reply

Your email address will not be published. Required fields are marked *