How to get list of logrotate files

拜拜、爱过 提交于 2019-12-24 19:16:28

问题


How can my program iterate through the log history created by logrotate?

logrotate has many options for file naming. For example, dateext, delaycompress, and rotate all affect the filenames in some way. I want my program to be Linux-friendly and work with most of these options.

I read the entire manpage of logrotate, and did not find any description of how other software can inspect the files that logrotate has produced. Is there perhaps some sister utility that understands what logrotate has done to my logfiles, and can make it easy to retrieve this information?


回答1:


After rereading the manpage 3 more times, I found the following words:

Note that the datestamps generated by this format must be lexically sortable ... when using the rotate option, logrotate sorts all rotated filenames to find out which logfiles are older

So we have a documented method for finding the files. For reverse chronological order, the sorting must be reversed when dateext is used, of course.



来源:https://stackoverflow.com/questions/46578307/how-to-get-list-of-logrotate-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!