问题描述
我是新来的logrotate。当配置使用属性 dateformat时,logrotate似乎不支持strftime%H。这里是配置:
I am newer to logrotate. when the configure comes to the property "dateformat",it seems that logrotate doesn't support strftime "%H" . here is the config:
。However, you can use %s in the dateformat string, which is the number of seconds since 1970-01-01. You can set dateformat -%Y%m%d-%s. This will produce unique filenames every time the log is rotated, so you can rotate the file multiple times a day. Unfortunately, the %s part will not be easy to read, but you can easily convert it back into a readable date with perl -e "print scalar(localtime(1451214849))".
在某些系统上, date 程序允许这样做转换只需 date -d @ 1451214849 即可(例如GNU date )。在大多数系统上(包括Solaris date ),您可能会碰巧使用 date -d 1970-01-01 + 1451214849 sec 。请注意,Busybox date 仅支持 @ 技巧,但不支持第二个示例的复杂表达式。
On some systems, the date program allows to do such conversion easily with date -d @1451214849 (e.g. GNU date). On most systems (including e.g. Solaris date), you may have luck with syntax like date -d "1970-01-01 + 1451214849 sec". Note that Busybox date supports only the @ trick but not complex expressions of the second example.
这篇关于logrotate dateformat似乎不支持%H:%M:%S的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!