I using syslog-ng config file destination
configuration to create hourly log files. The config I'm using for this is as follows:
destination d_hourly {file("/var/log/tracker/pid$PID-track-$YEAR-$MONTH-$DAY-$HOUR.log");};
I now have a requirement to create files every 15 mins or 30 mins. I looked through the config file macros and there is no such macro (which is on expected lines). Is there a way to write a custom function in syslog-ng config which returns a value based on the current time and which can be suffixed in the destination direction for syslog-ng.
Or is there some other way to achieve this?
Best Answer
You can divide the minute value by a number inline, which will generate separated files. For example:
Because of integer division, this will put all logs from PID 1000 and date 1/23/2015 05:00 to 05:29 into
and from 05:30 to 05:59 into
You can also increase the frequency by changing 30 to another divisor.