logの自動圧縮・削除-logrotateコマンド
20180630に記載 rijin123.icon
自動でrotate、圧縮、削除など
調べた時のmemo
logrotateコマンドがどういうものかは調べたらわかりますが、なぜapache, nginxではなくnodejsでwebサーバにした時に必要になったのかを知りたいですmoyamin.icon
おそらくapache, nginxだと同種の機能がすでに入っているということでしょうか?
入ってますね。一定サイズになると別ファイルに移動しますshokai.icon
/icons/なるほど.iconmoyamin.icon
logrotateは複数のログファイルを圧縮、削除、メールで送信するための機能
logrotate入門
ログローテーションするためのlogrotate設定とちょっとしたtips
service crond status
例 logrotate 設定ファイル
code:logrotate.conf
/var/log/node/error_log {
dateformat _%Y%m%d
compress #
copytruncate #copy の動作を行った後、元のログファイルの内容を消去する maxsize 3M
}
実行の仕方
デバック /usr/sbin/logrotate -fd /etc/logrotate.d/logrotate.conf
実行 /usr/sbin/logrotate -f /etc/logrotate.d/logrotate.conf
code: logrotate --help
$ logrotate --help
-d, --debug Don't do anything, just test (implies -v)
-f, --force Force file rotation
-m, --mail=command Command to send mail (instead of `/bin/mail')
-s, --state=statefile Path of state file
-v, --verbose Display messages during rotation
-l, --log=文字列 Log file
--version Display version information
Help options:
-?, --help Show this help message
--usage Display brief usage message`