ワーカープロセスではなく、基本プロセスのPIDをどのように取得できますか?

ワーカープロセスではなく、基本プロセスのPIDをどのように取得できますか?

CentOS 7を使用しています。プーマプロセスを開始および停止するスクリプトを作成しようとしていますが、「マスター」PIDを取得する方法がわかりません(正しい用語の場合)。次のコマンドで

[rails@server myproject_production]$ ps aux | grep puma
rails    15767  0.0  1.2 437904 13612 ?        Sl   17:20   0:00 puma 3.11.4 (tcp://0.0.0.0:3000,unix:///home/rails/myproject_production/shared/sockets/puma.sock) [myproject_production]
rails    15779  0.6  7.6 1061248 80688 ?       Sl   17:20   0:05 puma: cluster worker 1: 15767 [myproject_production]
rails    15781  0.6  7.7 1061248 80876 ?       Sl   17:20   0:05 puma: cluster worker 2: 15767 [myproject_production]
rails    15785  0.6  7.4 1061964 78488 ?       Sl   17:20   0:05 puma: cluster worker 3: 15767 [myproject_production]
rails    15880  0.7  7.4 1059612 78592 ?       Sl   17:22   0:05 puma: cluster worker 0: 15767 [myproject_production]
rails    17106  0.0  0.1 112612  1064 pts/0    S+   17:33   0:00 grep --color=auto puma

メインコントロールPIDは「15767」です。他のすべてのプーマプロセスを終了すると、そのプロセスも終了します。スクリプト変数を取得するコマンドを書くには?

ベストアンサー1

使用pgreppsあなたの場合は、正しいプロセスが一致すると思いますpgrep -f '^([^ ]*/)?puma '。しかし、あなたが望むものを得ることができるかどうかを確認するためにいくつかの実験をしてみてください。

pgrep終了したいプロセスを見つけたら、pgrepに置き換えますpkill

おすすめ記事