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
230
今インフラ技術をイチから学び直すなら
yuhta28
1
250
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
3
630
Datadog外形監視基盤をEC2から ECSへ移行してみた
yuhta28
0
1.7k
アウトプット頑張ったら企業からLT登壇の依頼がきた話
yuhta28
1
1.6k
小さなことから始めるAWSコスト最適入門
yuhta28
1
1.3k
Datadogのコストも監視しよう
yuhta28
1
980
Rcloneを使った定期的なストレージ同期
yuhta28
0
760
Pulumiを触ってみよう
yuhta28
1
2.6k
Other Decks in Programming
See All in Programming
Pythonに漸進的に型をつける
nealle
1
150
CSC509 Lecture 07
javiergs
PRO
0
250
KoogではじめるAIエージェント開発
hiroaki404
1
260
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
120
Introducing RemoteCompose: break your UI out of the app sandbox.
camaelon
2
370
社会人になっても趣味開発を続けたい! / traPavilion
mazrean
1
120
Temporal Knowledge Graphで作る! 時間変化するナレッジを扱うAI Agentの世界
po3rin
5
1.1k
Register is more than clipboard
satorunooshie
1
320
なんでRustの環境構築してないのにRust製のツールが動くの? / Why Do Rust-Based Tools Run Without a Rust Environment?
ssssota
14
47k
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
4
17k
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
Inside of Swift Export
giginet
PRO
1
300
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1k
Speed Design
sergeychernyshev
32
1.2k
Scaling GitHub
holman
463
140k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Typedesign – Prime Four
hannesfritz
42
2.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Keith and Marios Guide to Fast Websites
keithpitt
412
23k
Balancing Empowerment & Direction
lara
5
710
Raft: Consensus for Rubyists
vanstee
140
7.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コマンドの出力内容をパイプし てみた