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
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
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
410
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
5
1.8k
Vibe Coding で作ったプロダクトをどう安全に動かすか / How to Safely Run Products Built with Vibe Coding
glidenote
0
150
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
220
「ピッケル本」日本語版は4.0(第6版)が出版されるべき / pickaxe4-nagoyark05
kakutani
2
180
あるけみー式LTスライド作成術
alchemy1115
2
220
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
28
16k
「守り」で活用するオンデバイスLLM 〜写ってはいけないを総力戦で防ぐ〜 / iOSDC Japan 2026
nakamuuu
0
170
Claude Code本って、 読む必要あるの?
oikon48
2
480
10Xに技術的負債をもたらした「2つの境界の歪み」その構造と解消への営み
10xinc
0
2.1k
What the customer really needed
kawaguti
PRO
3
210
AI に書かせたその API、 “信頼” できますか?
nagix
0
120
Featured
See All Featured
We Are The Robots
honzajavorek
0
380
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Designing Experiences People Love
moore
143
24k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Paper Plane
katiecoart
PRO
4
53k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Faster Mobile Websites
deanohume
310
32k
Believing is Seeing
oripsolob
1
220
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
RailsConf 2023
tenderlove
30
1.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
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