Ubuntu 14.04 の LXC で CentOS 6 の特権コンテナをたてて外部から SSH できるようにした記録。
Keywords: Ubuntu LXC CentOS block device ブロックデバイス 特権コンテナ
続きを読む/usr/local/bin にある #!/usr/bin/python3
をみつけたい、場面です。
こんな感じ。
find /usr/local/bin -type file | xargs awk '/python3/ {print FILENAME} {nextfile}'
1行目だけ検査したらさっさと nextfile
で次に移るので OK というわけ。
nextfile Stop processing the current input file. The next input record read comes from the next input file. FILENAME and ARGIND are updated, FNR is reset to 1, and processing starts over with the first pattern in the AWK program. If the end of the input data is reached, the END block(s), if any, are executed.
追記
FNR
(行番号)を if で判定して nextfile
することで、任意の行数を処理できます。
あと、grep といいつつ awk なタイトル詐欺ですみません。
Linux 限定ですが、binfmt_misc を使えば shell script や Python と同じように実行ビットを立てるだけで実行できるようになります。
以下のスクリプトを /usr/local/bin/gorun
とでもして保存
#!/bin/sh exec go run "$@"
Debian/Ubuntu なら update-binfmts
があるので以下を実行
sudo update-binfmts --install go /usr/local/bin/gorun --extension go
Go スクリプトに実行ビットを立てる
chmod a+x hello.go
hello.go
が直接実行できるようになる
$ ./hello.go Hello World!
小ネタで頻出と思いますけど。
これまた誰かの役に立てばということで。
keepalived (VRRP)はその仕組み上、ネットワーク分断時にマスターが二つ以上できます。俗にいう、スプリットブレインというやつです。
ネットワーク分断が解消したのち、マスターは一つに収束します。ネットワークスイッチの類であれば大概の場合これで問題はありません。ええ、問題はないはずでした。
続きを読む