得到两个命令 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 之后运行?