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
480
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
how logrotate works
tokuhirom
April 11, 2020
Transcript
9 slides
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
Other Decks in Technology
See All in Technology
Kiro Enterprise Management: 管理者が 1 か所で決め、全員の Kiro に届ける
inariku
PRO
1
160
技術同人誌を作る方法
yoshimura_datam
0
110
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
5
18k
「個社」ではなく「業界」の課題を解く AI 対話開発 ー 価値を広げる設計と、価値を守るエンジニアリング ー
ivry_presentationmaterials
4
920
Fukurou Labo_Engineer_Deck
fukuroulabo
0
120
Webメール開発を大幅に変えたJMAPというゲームチェンジャー
tascript
9
5.8k
品質を積み上げられるようにする
goyoki
5
1.5k
その修正で本当に速くなったのか? k6とOpenTelemetryで確かめる性能改善 / Performance review with k6 and OpenTelemetry
ymotongpoo
3
480
Ignite 2026 Security
babaneko
0
110
「それ、AIでよくない?」- AI時代の技術発信はオワコンなのか?
estie
1
110
メディアアートを〈拡張〉する——器官学と個体化論を手がかりに
_kotobuki_
1
390
kubellの最新データ分析環境
kubell_hr
2
290
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
340
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
We Are The Robots
honzajavorek
0
470
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Prompt Engineering for Job Search
mfonobong
0
610
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
3
180
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
620
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
360
Facilitating Awesome Meetings
lara
57
7.2k
Designing Experiences People Love
moore
143
24k