linux - 如何在 Linux 终端中有两个正在运行的进程?(Linux 命令)
问题描述
我正在关注 React + Apollo 教程,但不得不停下来要求我同时运行服务器和应用程序。我尝试先通过当前目录中的 'yarn start' 运行应用程序,并在终止应用程序 'ctrl + c' 后移动到 'server' 目录以通过 'yarn dev' 运行服务器,这没有运行两件事同时。
我做了什么
在阿波罗目录
纱线开始
ctrl + c
光盘服务器
在服务器目录中
纱线开发
如何同时运行服务器(在服务器目录中)和应用程序(在 apollo 目录中)?谢谢!
解决方案
我认为最简单的方法是:
program1 &
program2 &
这将在后台运行这两个程序。如果将其用作脚本的一部分,您也可以使用wait
它。
您可能会发现其他有用的命令:
jobs # prints all jobs running in the background
fg [job_id] - foreground, brings the program to the front.
bg [job_id] - background, sends a program to the background.
CTRL+Z - suspends a job running in the front. You'll be able to see it when running jobs.
还有其他一些选择。要深入理解这一点,您需要熟悉进程作为操作系统的一部分是如何工作的。
推荐阅读
- javascript - 条纹结帐按钮在移动设备上没有任何作用
- netsuite - 从父自定义记录类型访问子自定义记录类型
- ocaml - not sure what is wrong in this implementation
- azure - Azure-Powershell 脚本错误(IP 地址增量)
- r - Using `pool` in an R Shiny package
- android - How to customize android style in FirebaseUI
- c++ - How would I make a UTF-8 letter code when i have its binary equivalent? C++
- python - Djangon 2.2 filtering a single data set across pages
- php - How to validate complex JSON array in PHP Laravel
- powershell - Add-Content -PassThru is writing to file but not passing output to console