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
YouYou
June 20, 2021
Programming
0
1.5k
nginxコマンドの出力結果をパイプしてみた
詳細ブログ↓
https://zenn.dev/yuta28/articles/nginx-output-pipe
YouYou
June 20, 2021
Tweet
Share
More Decks by YouYou
See All by YouYou
AWSマネコンに複数のアカウントで入れるようになりました
yuhta28
2
220
今インフラ技術をイチから学び直すなら
yuhta28
1
240
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
3
620
Datadog外形監視基盤をEC2から ECSへ移行してみた
yuhta28
0
1.6k
アウトプット頑張ったら企業からLT登壇の依頼がきた話
yuhta28
1
1.5k
小さなことから始めるAWSコスト最適入門
yuhta28
1
1.2k
Datadogのコストも監視しよう
yuhta28
1
960
Rcloneを使った定期的なストレージ同期
yuhta28
0
730
Pulumiを触ってみよう
yuhta28
1
2.5k
Other Decks in Programming
See All in Programming
STUNMESH-go: Wireguard NAT穿隧工具的源起與介紹
tjjh89017
0
390
SOCI Index Manifest v2が出たので調べてみた / Introduction to SOCI Index Manifest v2
tkikuc
1
110
TDD 実践ミニトーク
contour_gara
1
200
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1.2k
Rancher と Terraform
fufuhu
1
120
rage against annotate_predecessor
junk0612
0
100
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
280
AHC051解法紹介
eijirou
0
630
Introduction to Git & GitHub
latte72
0
120
学習を成果に繋げるための個人開発の考え方 〜 「学習のための個人開発」のすすめ / personal project for leaning
panda_program
1
110
MCPで実現するAIエージェント駆動のNext.jsアプリデバッグ手法
nyatinte
7
950
個人軟體時代
ethanhuang13
0
110
Featured
See All Featured
How to Ace a Technical Interview
jacobian
279
23k
BBQ
matthewcrist
89
9.8k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Designing Experiences People Love
moore
142
24k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
What's in a price? How to price your products and services
michaelherold
246
12k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
Scaling GitHub
holman
462
140k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
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コマンドの出力内容をパイプし てみた