I want to delete logs which are older than 6 months from this file.
I'm not clear what you mean but if I had to guess, you want to remove logfile entries from this file which are older than 6 months. If that's the case, it can be done but it's a rather extraordinary way of managing logs on a *nix system.
What you want to do (if my assumption is correct) is going to require parsing each line from that file and determining the timestamp in order to test if the entry date is within your current 6 month window. Depending on a pass/fail of the timestamp you would write out the new logfile without the "old" entries. You could use shell tools such as grep
and head
and tail
to achieve this but in the interest of performance you may want to consider a custom compiled C application specifically tailored for what you need.
I don't know what kind of hardware this logfile is on but the sheer size of this logfile (6.8 Gigabytes) will likely cause significant performance bottlenecks when parsing the old entries and writing the new ones. In most cases when things are this much trouble it's usually a sign the process is in need of review. There are corner cases to that rule however. Good luck.