rsyslog and zipping up "rotated" files

General support questions
Post Reply
didds2
Posts: 4
Joined: 2017/04/27 11:45:49

rsyslog and zipping up "rotated" files

Post by didds2 » 2017/04/27 11:49:31

I have a rsyslog config that suffixes the date to the filename and holds the log files in a non stabdard log directory based on its srver name (long story).


Example -
config includes:

...
$template mailLog,"/var/log/external/%fromhost%/maillog-%$YEAR%%$MONTH%%$DAY%.log"
...
# Log all the mail messages in one place.
mail.* -?mailLog
...

so that I get over time

..
/var/log/external/server/maillog-20170424.log
/var/log/external/server/maillog-20170425.log
/var/log/external/server/maillog-20170426.log

etc.

Over time of course these build up, so i have a cronjob to trim any such logs okder than 30 days. To also save on space I copmpress all the files except todays via a cronjobbed script.

so in fact I get

...
/var/log/external/server/maillog-20170424.log.gz
/var/log/external/server/maillog-20170425.log.gz
/var/log/external/server/maillog-20170426.log


My questions are therefore...

- is there a way for rsyslog to compress these logs once a new log is created at midnight
- is theer a way for rsyslog to remove any logs older than 30 days?

I am of course aware that logrotate does this also, but for the purposes of my inquiry I am only interested in using rsyslog if at all possible.

I expect the removing of older, zipped logs via rsyslog isn't available. But the possibility of zipping files would be of great interest.

cheers

Ian

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: rsyslog and zipping up "rotated" files

Post by TrevorH » 2017/04/27 12:05:41

You may not like it but the answer is logrotate. Sorry.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

didds2
Posts: 4
Joined: 2017/04/27 11:45:49

Re: rsyslog and zipping up "rotated" files

Post by didds2 » 2017/04/27 13:21:20

TrevorH wrote:You may not like it but the answer is logrotate. Sorry.
LOL. That's not a problem Trevor :-)

If it doesn't do it, it doesn't do it.

At least Ive exhausted the possibilities.

cheers


didds

Post Reply