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
nginxコマンドの出力結果をパイプしてみた
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
YouYou
June 20, 2021
Programming
1.6k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
nginxコマンドの出力結果をパイプしてみた
詳細ブログ↓
https://zenn.dev/yuta28/articles/nginx-output-pipe
YouYou
June 20, 2021
More Decks by YouYou
See All by YouYou
AWSマネコンに複数のアカウントで入れるようになりました
yuhta28
2
300
今インフラ技術をイチから学び直すなら
yuhta28
1
310
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
3
680
Datadog外形監視基盤をEC2から ECSへ移行してみた
yuhta28
0
1.8k
アウトプット頑張ったら企業からLT登壇の依頼がきた話
yuhta28
1
1.9k
小さなことから始めるAWSコスト最適入門
yuhta28
1
1.4k
Datadogのコストも監視しよう
yuhta28
1
1.1k
Rcloneを使った定期的なストレージ同期
yuhta28
0
850
Pulumiを触ってみよう
yuhta28
1
2.7k
Other Decks in Programming
See All in Programming
自作OSでスライド発表する
uyuki234
1
3.9k
フィードバックで育てるAI開発
kotaminato
1
120
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
810
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
110
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
symfony/aiとlaravel/boost
77web
0
140
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
510
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
670
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
500
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
290
AIが無かった頃の素敵な出会いの話
codmoninc
1
130
Featured
See All Featured
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
WENDY [Excerpt]
tessaabrams
11
38k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The SEO identity crisis: Don't let AI make you average
varn
0
520
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
The Curse of the Amulet
leimatthew05
2
13k
Building Applications with DynamoDB
mza
96
7.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
390
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
190
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Transcript
nginxコマンドの出力結果を パイプしてみた
Name:ユータ Occupation:インフラエンジニア Twitter:@Y0u281 (オーでなくゼロです) ブログ:https://zenn.dev/yuta28 → 普段触るもの:AWS Ansible Linux Mint
自己紹介 Twitter
目次 • 背景 • 原因 • やったこと • まとめ
背景 • 運用しているメディアサーバーの棚卸し ◦ Apacheかnginxか • 出力結果を加工してバージョン情報だけ抽出 $ httpd -v
Server version: Apache/2.2.34 (Unix) Server built: Nov 1 2017 18:47:16 $ httpd -v | head -n 1 | cut -f 3 -d " " Apache/2.2.34
背景 • nginxだとうまくいかない🤔 • ファイルにも出力されない $ nginx -v nginx version:
nginx/1.18.0 $ nginx -v | head -n 1 | cut -f 3 -d " " nginx version: nginx/1.18.0 $ nginx -v > test.txt nginx version: nginx/1.18.0 $ cat test.txt $
原因 ファイルディスクリプタが違っていた!!
ファイルディスクリプタについて • ファイル操作に割り当てられる整数値 • 以下が一般的 ◦ 0:stdin(標準入力) ◦ 1:sdout(標準出力) ◦
2:stderr(標準エラー出力) • 出力結果を渡すパイプはデフォルトでは標準出力のみ対応 $ httpd -v | head -n 1 | cut -f 3 -d " " Apache/2.2.34
やったこと $ nginx -v 2>&1 | cut -f 3 -d
" " nginx/1.18.0 書式 説明 コマンド1 | コマンド2 コマンド1 の「標準出力」をコマンド2 の「標準入力」に引き渡す コマンド1 2>&1 | コマンド2 コマンド1 の「標準出力」と「エラー出力」をコマンド2 の 標準入力に引き渡す 引用 Linux - ストリーム、パイプ、リダイレクトの使用
まとめ なぜnginxは標準エラー出力? 🤔🤔🤔 • 標準出力 • 標準エラー出力 それぞれ引き渡しが異なる
ありがとうございました 詳細は私のブログで ↓ nginxコマンドの出力内容をパイプし てみた