Shell

如何在執行前台程序時在後台生成單獨的程序

  • August 17, 2017

例如,我想在後台執行一個 python -m HTTPSimpleServer 同時在後台執行一個手錶

python -m HTTPSimpleServer;watch -n(我很棒的測試命令)

如何從一個命令並行執行兩者。

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

試試看:

python -m HTTPSimpleServer & watch -n

引用自:https://unix.stackexchange.com/questions/285968