官术网_书友最值得收藏!

Running a command in the background

There are some situations in which you might want to continue running other commands as you wait for another one to complete, to run more than one job in parallel. You can arrange for a command to run in the background by ending it with a single ampersand (&) control operator.

You can try this out by issuing a sleep command in the background. The sleep built-in Bash command accepts a number of seconds to wait as an argument. If you enter such a command without the &, Bash won't accept further commands until the command exits:

$ sleep 10
# Ten seconds pass... $

However, if you add the & terminator to start the job in the background, the behavior is different: you get a job control number and a process ID, and you are returned immediately to your prompt:

$ sleep 10 &
[1] 435
$

You can continue running other commands as normal while this job is running in the background. After the 10 seconds are up, the next time the prompt appears, it will also print output telling you the job has completed:

[1]+  Done                    sleep 10
$
主站蜘蛛池模板: 榆林市| 庆云县| 奇台县| 蒙阴县| 泸溪县| 湘潭县| 北流市| 东港市| 花垣县| 磐安县| 闸北区| 抚松县| 措勤县| 连平县| 大庆市| 定西市| 湘乡市| 宜兰市| 鄢陵县| 察哈| 洛阳市| 紫阳县| 铜陵市| 油尖旺区| 自治县| 太原市| 通城县| 新源县| 邵武市| 吴桥县| 台州市| 楚雄市| 乌鲁木齐市| 曲松县| 丹东市| 突泉县| 普兰店市| 德安县| 海阳市| 炉霍县| 二连浩特市|