Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
Agentic AI 時代のテスト手法: Kiro とはじめるプロパティベーステスト (AWS Summit Japan 2026 | DEV212)
ymhiroki
0
200
4人目のSREはAgent
tanimuyk
0
380
Docker Desktop不要の時代が来る? WSL標準の「wslc」で Linuxコンテナを動かしてみた.
ueponx
0
660
Baseline対応のDOMの型定義を作った
uhyo
3
680
AIに「使われる」時代のSaaS戦略 〜既存WebAPIのMCPサーバー化における開発ノウハウ〜
ekispert_api
0
290
そのハーネス、本当に境界になっていますか? AIエージェント時代の実行環境設計【MEGU-Meet #4】
cscengineer
PRO
0
110
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
530
AWS Blocks を触ってみた/first-tach-aws-blocks
fossamagna
2
140
どうして今サーバーサイドKotlinを選択したのか
nealle
0
190
プライバシー保護の理論と実践
lycorptech_jp
PRO
1
240
Zoom2Youtube.Claude
kawaguti
PRO
1
190
AWS Summit の片隅で、体育座りしながらコミュニティがにぎわう理由を考えた
k_adachi_01
2
350
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
290
WCS-LA-2024
lcolladotor
0
670
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
270
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
960
Code Reviewing Like a Champion
maltzj
528
40k
Thoughts on Productivity
jonyablonski
76
5.2k
Building Adaptive Systems
keathley
44
3.1k
HDC tutorial
michielstock
2
730
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
A designer walks into a library…
pauljervisheath
211
24k
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