E-Mail:

How do I rotate files in Unix?

On Solaris I have cron job which creates some log files and it puts it under a directory, this directory name is created based on system date for example directory name are like 08162005, 08172005 so on..

What I need is I want to do a rotation for these log directories every 14 days since these are directories with system dates, I am having little trouble getting this done,

Is there any way you can solve this for me??

If you’re trying to figure out how to do date math, then this is going to seem like a very difficult task. But, in fact, what you’re talking about is a perfect job for one of the Swiss Army Knives of the Unix command line: find.

Specifically, find has a flag -ctime which lets you test how long ago the file was created. The notation that the program uses for specifying dates is a bit confusing, but I’ll give you a shortcut…

What Do You Think?

 

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

66 queries / 0.412 seconds.