linux - Manage ctrl+z and bg or & signal in shell script - (shell脚本中的后台进程)

标签 linux angular shell sh

我有一个包含在里面的脚本:

cd $1
ng s --host 0.0.0.0 --port 4200
...another commands ... 

所以,我想在里面运行一个 Angular 项目。我正在从微服务执行脚本,所以实际上由于 ng s 命令的行为,该服务永远不会给我回复响应。 enter image description here

记住这一点,我想在后台执行“ng s ...”命令,但是当我运行时:

ng s --host 0.0.0.0 --port 4200 &

ng s 将 & 作为无效参数。我的意思是,我尝试以多种方式在后台运行脚本,但没有成功

我怎样才能做到这一点?

最佳答案

作为一种选择,您可以写下一个简短的 bash 脚本,其中只包含

#!/bin/bash
ng s --host 0.0.0.0 --port 4200

然后以

开始

脚本.sh &

或者如果您想在与终端断开连接后继续运行:

nohup 脚本.sh &

关于linux - Manage ctrl+z and bg or & signal in shell script - (shell脚本中的后台进程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53780927/

相关文章:

c++ - 如何在 C++ 中将所有输入 (cin) 记录到文件中

linux - 列出进程以有效方式访问的所有文件

linux - epoll 可以在可用时完全取代 select/poll 吗?

Angular 4 get函数在http post请求后返回值

linux - Shell 脚本定时任务

linux - 如何将指定目录复制到目录一次?

android - Android app如何知道底层硬件支持某种硬件解码加速?

Java KeepAlive 检查程序不为 .checkError 返回 true

arrays - Angular 6 : get array of objects from corresponding JSON through httpClient

json - 将 res.json() 转换为 Array<Object>