###やりたい事
nginxのログローテートを動作するようにして、日毎でファイルを分け、一定期間が経過したものは削除したい。
###現状
/etc/logrotate.d
にあるnginxの設定は以下の通りです。
➜ logrotate.d cat nginx /var/log/nginx/*log { create 0644 nginx nginx daily rotate 10 missingok notifempty compress delaycompress sharedscripts postrotate /etc/init.d/nginx reopen_logs endscript }
/etc/init.d
にあるnginxは以下の通りでした。
# Tell nginx to reopen logs reopen_logs() { configtest_q || return 6 echo -n $"Reopening $prog logs: " killproc -p $pidfile $prog -USR1 retval=$? echo return $retval }
またこの記事を参考に以下のコマンドを実行しています。
logrotate /etc/logrotate.conf
これで日付が変わればnginxのログファイルがローテーションされるはずなのですが、nginx.access.log
というファイルに書き込まれ続けます。
なお実行権限は以下のようになっています。
➜ /etc ll /etc/logrotate.d/nginx -rw-r--r-- 1 root root 222 Jan 10 08:35 /etc/logrotate.d/nginx
###聞きたい事
一体何がうまくいっていないのでしょうか??もし見当がつきそうであれば教えていただけると幸いです。
###追記
以下のコマンドを実行した結果です。
(1) logrotate -d /etc/logrotate.d/nginx (2) logrotate -d -f /etc/logrotate.d/nginx
➜ git:(master) logrotate -d /etc/logrotate.d/nginx reading config file /etc/logrotate.d/nginx reading config info for /var/log/nginx/*log Handling 1 logs rotating pattern: /var/log/nginx/*log after 1 days (10 rotations) empty log files are not rotated, old logs are removed not running postrotate script, since no logs were rotated ➜ git:(master) logrotate -d -f /etc/logrotate.d/nginx reading config file /etc/logrotate.d/nginx reading config info for /var/log/nginx/*log Handling 1 logs rotating pattern: /var/log/nginx/*log forced from command line (10 rotations) empty log files are not rotated, old logs are removed not running postrotate script, since no logs were rotated
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/10 06:12
2018/01/10 06:15
2018/01/10 06:54
2018/01/10 12:27 編集
2018/01/10 14:36