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.3k
nginxコマンドの出力結果をパイプしてみた
詳細ブログ↓
https://zenn.dev/yuta28/articles/nginx-output-pipe
YouYou
June 20, 2021
Tweet
Share
More Decks by YouYou
See All by YouYou
今インフラ技術をイチから学び直すなら
yuhta28
1
170
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
2
540
Datadog外形監視基盤をEC2から ECSへ移行してみた
yuhta28
0
1.5k
アウトプット頑張ったら企業からLT登壇の依頼がきた話
yuhta28
1
1.1k
小さなことから始めるAWSコスト最適入門
yuhta28
1
950
Datadogのコストも監視しよう
yuhta28
1
770
Rcloneを使った定期的なストレージ同期
yuhta28
0
510
Pulumiを触ってみよう
yuhta28
1
2k
ログストレージコスパ最強!?OpenObserveを試してみた
yuhta28
0
3.3k
Other Decks in Programming
See All in Programming
テスト駆動開発✅️
akitoshiga
1
180
Новый уровень ML-персонализации Lamoda: Как мы усилили ее в каталоге и перенесли на другие продукты
lamodatech
0
420
メルカリ ハロ アプリの技術スタック
atsumo
2
910
Modern Angular with Lightweight Stores: New Rules and Options
manfredsteyer
PRO
0
200
Memory API: Patterns, Use Cases, and Performance
josepaumard
2
210
CSC305 Lecture 13
javiergs
PRO
0
110
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1.3k
Competitionsだけじゃない! Kaggle Notebooks Grandmasterのすすめ
corochann
2
940
空間の中でアイドルとレッスンする技術 - 1st "Vision" / Spatial Lesson technologies with my idol - 1st "Vision"
banjun
PRO
0
260
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
2.4k
GPU Hash Table | レイトレ合宿10
yknishidate
0
350
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
160
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
334
57k
Writing Fast Ruby
sferik
626
60k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Building Your Own Lightsaber
phodgson
102
6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
327
21k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.7k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
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コマンドの出力内容をパイプし てみた