I have logs in the following format: YYYYMMDD
I want to compress old logs (older then current day) and maybe move them to a different directory afterwards.
Can I do this in logrotate, or do I have to use a custom script in cron?
|
|
|
Here's a quickie script which will do what you need:
Make the script executable:
The crontab entry will look like:
Just adjust |
|||||
|
|
|
|||
|
|
|
logrotate can do it with olddir if your log file name is the same every time it runs and you can add dates. If your log file name changes i.e. YYYYMMDD then logrotate won't do it for you.
Copies and gzips /logs/sys.log to /logs/logarchive/sys.20120101.log.gz, keeps one week worth of logs. |
||||
|
|