Production Level Knowledge & Tips

  1. 未分類
  2. 37 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

未分類 recent post

  1. Install sbt 1.0.0 and run sample template

  2. Visualization of Neural Network and its Train…

  3. [Machine Learning]Created docker image includ…

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

  5. [Hive]Get top n items for each category

関連記事

PAGE TOP