フォアグラウンドプロセスの実行中にバックグラウンドで別々のプロセスを作成する方法

フォアグラウンドプロセスの実行中にバックグラウンドで別々のプロセスを作成する方法

たとえば、バックグラウンドでウォッチを実行しながら、バックグラウンドでpython -m HTTPSimpleServerを実行したいとします。

python -m HTTPSimpleServer; watch -n(私の素晴らしいテストコマンド)

1つのコマンドで2つを並列に生成する方法

ベストアンサー1

python -m HTTPSimpleServer &  # Your Python process will now be in the background
serverpid="$!"                # Capture its PID so that you can kill it later.
watch -n /path/to/AwesomeTestCommand Arg1 Arg2
# Some time later...
kill "$serverpid"             # Make your Python process go away

おすすめ記事