Link to home
Start Free TrialLog in
Avatar of V Thrusher
V Thrusher

asked on

Need a shell script to zip the logfiles which are older than the current date

Monthly once we need to zip the log files, which are older than the current date
Avatar of serialband
serialband
Flag of Ukraine image

The logrotate package already does this in Linux.  There is a logrotate package for windows that was ported from cygwin.  https://github.com/plecos/logrotatewin  https://itefix.net/logwot8

For Windows, you can schedule a command line winzip
http://www.ga-experts.com/downloads/log_file_rotation.pdf

Someone also created their own logrotate script back before the cygwin ports.
http://www.datori.org/logrotatew/
Avatar of Bill Prew
Bill Prew

What operating system are you working on?

~bp
Avatar of V Thrusher

ASKER

its a AIX server
You can download and compile the logrotate source http://www.perzl.org/aix/index.php?n=Main.Logrotate
Or you set your own cron job and script the zip.
But i'm looking for  a my own script, so i can customize to my need, instead of using log rotate
That wasn't mentioned in your initial question, but you can also customize logrotate.
ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
find FILE-PATH -type f -name "*.log" -mtime +1-exec ls -lrt {} \;             ### lists the files to verify before running the below command
find FILE-PATH -type f -name "*.log" -mtime +1-exec tar -cvf <dirname> {} \;

note:
FILE-PATH - location of your file resides
"*.log" can be customized as per your need.
dirname - any directory name