Alone as an Island What’s the pride in being a Programmer?
Mar 02

It common to get a huge backlog of log files in any application. Worse is the case when the application has a batch interface too.  And there comes the need to delete the files which are older comes up. Or you might want to just copy/move the files to an archive folder for later reference.

Here are the unix commands for them :

Copy to archive folder

Consier your log folder is /apps/myapp/data/logs and your archive folder is /apps/myapp/archive/logs and you want to copy “files” and not directories which are 5 days old , then

find /apps/myapp/data/logs -type f -mtime +5 -name '*.log' - exec cp {} /apps/myapp/archive/logs \;

and/or if you want to delete the files which are 5 days old,

find /apps/myapp/data/logs -type f -mtime +5 -name '*.log' - exec rm -f {} \;

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis

Leave a Reply

Give your best to the world.