2

An application has a log directory in which a a lot of log output is created. The file structure in this log directory looks something like this:

localhost:/var/log/myapp # ls

appClient22334.a    appClient22336.a    appClient22338.a
appClient22334.b    appClient22336.b    appClient22338.b    
appClient22334.c    appClient22336.c    appClient22338.c
appClient22335.a    appClient22337.a    appClient22339.a
appClient22335.b    appClient22337.b    appClient22339.b
appClient22335.c    appClient22337.c    appClient22339.c

Every day, the application generates hundreds of those files, which are all to be stored. The numbers increment.

For most purposes, I use logrotate to store and compress log files on a daily basis, but in this case I fail to see how this could be done.

The ideal solution would be to have something like

appClient.20120324.gzip
appClient.20120325.gzip
appClient.20120326.gzip

Can anyone of you nudge me into the right direction, if this can be done while using logrotate (maybe a clever way to use prerotate?), or if it is faster/easier to write a specific bash script?

2
  • You say that there are hundreds of files per day. Shall they all be gathered into single per-day logfile?
    – Netch
    Commented Mar 28, 2012 at 7:46
  • Yes, thats the plan.
    – Bjoern
    Commented Mar 28, 2012 at 7:51

1 Answer 1

1

In the interest of keeping things simple, I'd run a daily cron job that concatenates yesterday's log files into one file (e.g. yesterday.log) and on success deletes them, and then run logrotate to (re)name and compress that file. You might be able to coerce logrotate into doing the whole task using sharedscripts but I don't think so and I wouldn't waste time trying to figure it out.

1
  • Good thinking, I'll follow this approach.
    – Bjoern
    Commented Apr 28, 2012 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .