小编use*_*767的帖子

在后台运行多个 nohup 命令

得到两个命令 cmd1 和 cmd2。在这两者中,cmd2 需要更长的时间才能完成。需要先运行cmd2,然后再运行cmd1。

尝试以下列方式运行它们:

bash$ (nohup ./cmd2>result2 &) && nohup ./cmd1>result1 &
Run Code Online (Sandbox Code Playgroud)

或者

bash$ (nohup ./cmd2>result2 &) ; nohup ./cmd1>result1 &
Run Code Online (Sandbox Code Playgroud)

但是两次我都可以看到 cmd1 没有等待 cmd2 完成并且 result1 被填满。

当两者都应该是 nohup 进程并在后台运行时,如何让 cmd1 在 cmd2 之后运行?

shell process nohup background-process

17
推荐指数
2
解决办法
6万
查看次数

标签 统计

background-process ×1

nohup ×1

process ×1

shell ×1