/var/log 配下に作成される
syslog.2.gz
syslog.3.gz
syslog.4.gz
上記のファイル名を
syslog.YYY.MM.DD.gzに変更する方法を教えていただきたく。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答1件
0
ベストアンサー
OS がわかりませんが、 linux なら rsyslog じゃなくて、logrotate ではないでしょうか?
logrotate のファイル名をデフォルトから変更する方法は、マニュアル
logrotate(8) - Linux man page の Configuration File に
dateext
Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number. The extension may be configured using the dateformat option.
dateformat format_string
Specify the extension for dateext using the notation similar to strftime(3) function. Only %Y %m %d and %s specifiers are allowed. The default value is -%Y%m%d. Note that also the character separating log name from the extension is part of the dateformat string. The system clock must be set past Sep 9th 2001 for %s to work correctly. Note that the datestamps generated by this format must be lexically sortable (i.e., first the year, then the month then the day. e.g., 2001/12/01 is ok, but 01/12/2001 is not, since 01/11/2002 would sort lower while it is later). This is because when using the rotate option, logrotate sorts all rotated filenames to find out which logfiles are older and should be removed.
とありますので、 /etc/logrotate.d/ にある対象ログファイルの設定ファイルに
ファイル名の形式が、log-YYYYMMDD なら dateext
を
ファイル名の形式が、log-YYYY.MM.DD なら dateformat %Y.%m.%d
を
設定してください。
投稿2018/09/05 07:59
編集2018/09/05 23:09総合スコア25171
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/06 02:44