我如何在一个单一的线路上运行在bash多个后台命令? [英] How do I run multiple background commands in bash in a single line?

查看:118
本文介绍了我如何在一个单一的线路上运行在bash多个后台命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常运行多个命令像这样:

I normally run multiple commands with something like this:

sleep 2 && sleep 3

sleep 2 ; sleep 3

但如果我想从一个命令行命令后台运行,他们两个?

but what if I want to run them both in the background from one command line command?

sleep 2 & && sleep 3 &

不起作用。而且也没有更换&放大器;&安培; ;

有没有办法做到这一点?

Is there a way to do it?

推荐答案

你到底要怎么他们跑?如果你希望他们在后台启动,并运行的连续的,你会做这样的事情:

Exactly how do you want them to run? If you want them to be started in the background and run sequentially, you would do something like this:

(sleep 2; sleep 3) &

如果,在另一方面,你想他们在运行的平行的背景,而是可以做到这一点:

If, on the other hand, you would like them to run in parallel in the background, you can instead do this:

sleep 2 & sleep 3 &

和两种技术可以合并,如:

And the two techniques could be combined, such as:

(sleep 2; echo first finished) & (sleep 3; echo second finished) &

猛砸是bash中,还有与它们之间的细微差别往往是不同的技术来完成相同的任务众多,虽然有时。

Bash being bash, there's often a multitude of different techniques to accomplish the same task, although sometimes with subtle differences between them.

这篇关于我如何在一个单一的线路上运行在bash多个后台命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆