Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
how logrotate works
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
tokuhirom
April 11, 2020
Technology
460
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
how logrotate works
tokuhirom
April 11, 2020
Other Decks in Technology
See All in Technology
分析AIエージェントを育てる、動く環境を育てる
codatum
1
820
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
160
今さら理解するウェブフォントver.2026
takanorip
3
660
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
170
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
780
今こそ知りたいAmplifyGen2
mkdev10
2
160
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
4
1.3k
子育てエンジニアの可処分時間が減っても成長を諦めない戦い方
sudoakiy
6
4.4k
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
290
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
150
Kiro Crewをはじめよう
kizawa2020
1
140
hackers_champloo_2026_tidb
makocchi
0
110
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Raft: Consensus for Rubyists
vanstee
142
7.7k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Designing for Performance
lara
612
70k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
KATA
mclloyd
PRO
35
16k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Transcript
logrotate の仕組み
Logrotate とは? • https://linux.die.net/man/8/logrotate • https://github.com/logrotate/logrotate • ログファイルをローテーションするプログラム • デーモンではなく
cron で実行されている。
本スライドでは以下のような設定を想定 /var/log/nginx/*log { daily # 一日一回 rotate(hourly, monthly, yearly なども指定可能)
missingok # 元ファイルがなくてもエラーにしない rotate 1 # 1世代を保持 compress # 古いファイルを圧縮する delaycompress # mv した回の次の rotate のタイミングで圧縮する notifempty # ファイルが空だったら rotate しない create 640 www www # www ユーザーで、file mode 640 で新規ファイルを作成 sharedscripts # パターンにマッチするファイルが複数個あっても一回しか # postrotate が実行されないようにする postrotate # rotate 後に、以下のスクリプトを実行する [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` endscript } /etc/logrotate.d/nginx 等に配置。
access.log-20200408 access.log-20200407.gz Nginx が access.log にログを書いている。 access.log nginx
access.log-20200409 logrotate access.log access.log-20200408 access.log-20200407.gz logrotate がファイルをmv する。 nginx はファイルを開いたままなので古いファイルに書き続ける
nginx mv access.log access.log-20200409
access.log-20200409 logrotate access.log access.log-20200408 access.log-20200407.gz `create 640 www www` が指定されているので新規に
access.log を作成する。 nginx touch access.log
nginx access.log-20200409 logrotate kill –USR1 $(cat /var/run/nginx.pid) access.log access.log-20200408 access.log-20200407.gz
logrotate が nginx にシグナル SIGUSR1 を送信する。 nginx は “access.log” を開き直す。以後は新しいファイルにログが書き込まれ る。
nginx access.log-20200409 logrotate gzip -9 access.log-20200408 access.log access.log-20200408.gz access.log-20200407.gz logrotate
は古いファイルを圧縮する。
nginx access.log-20200409 logrotate rm access.log-20200407.gz access.log access.log-20200408.gz logrotate はめっちゃ古いファイルを自動削除する。 access.log-20200407.gz