プログラミング + アカデミック + 何か面白いこと

  1. Programming
  2. 117 view

[Nginx][Cronolog]Simple Log rotation

Overview

Set log rotation with Cronolog.

Environment

  • OS
    • Linux www4322gi 3.2.0-64-generic #97-Ubuntu SMP Wed Jun 4 22:04:21 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Work flow

1.Check log setting of Nginx

If you change the setting, do not forget to restart.

sudo vim /etc/nginx/sites-available/main
-----
access_log /home/www/logs/access.log;
error_log /home/www/logs/error.log;
-----
sudo /etc/init.d/nginx restart

2.Install Cronolog

sudo apt-get install cronolog

3. Remake log files

rm /home/www/logs/access.log
rm /home/www/logs/error.log
mkfifo /home/www/logs/access.log
mkfifo /home/www/logs/error.log

4. Setting of Cronolog

tail -f /home/www/logs/access.log | /usr/bin/cronolog /home/www/logs/access.%Y-%m-%d.log
tail -f /home/www/logs/error.log | /usr/bin/cronolog /home/www/logs/error.%Y-%m-%d.log

Reference

http://hiroyukim.hatenablog.jp/entry/2012/05/09/111551

Programming recent post

  1. Install sbt 1.0.0 and run sample template

  2. [Machine Learning]Created docker image includ…

  3. [Node.js]How to write batch script with Node.…

  4. [Play][Scala]Develop Request Driven Batch Usi…

  5. [OpenCV][Ruby]Auto check web page design corr…

関連記事

PAGE TOP