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
970
Rcloneを使った定期的なストレージ同期
yuhta28
0
730
Pulumiを触ってみよう
yuhta28
1
2.5k
Other Decks in Programming
See All in Programming
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
400
複雑なフォームに立ち向かう Next.js の技術選定
macchiitaka
2
240
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
300
基礎から学ぶ大画面対応(Learning Large-Screen Support from the Ground Up)
tomoya0x00
0
4.3k
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
350
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
24
12k
rage against annotate_predecessor
junk0612
0
170
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
440
今だからこそ入門する Server-Sent Events (SSE)
nearme_tech
PRO
3
260
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
230
テストカバレッジ100%を10年続けて得られた学びと品質
mottyzzz
2
610
Android端末で実現するオンデバイスLLM 2025
masayukisuda
1
170
Featured
See All Featured
Visualization
eitanlees
148
16k
Navigating Team Friction
lara
189
15k
The Cult of Friendly URLs
andyhume
79
6.6k
Practical Orchestrator
shlominoach
190
11k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
Into the Great Unknown - MozCon
thekraken
40
2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
GraphQLの誤解/rethinking-graphql
sonatard
72
11k
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コマンドの出力内容をパイプし てみた