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

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
$
主站蜘蛛池模板: 双鸭山市| 洪江市| 察雅县| 蕉岭县| 阿尔山市| 获嘉县| 南溪县| 尉犁县| 晋中市| 延吉市| 台山市| 石泉县| 瑞丽市| 伊春市| 邮箱| 呼伦贝尔市| 玉林市| 平江县| 平度市| 镇赉县| 永宁县| 南岸区| 岳阳县| 朔州市| 区。| 德兴市| 深州市| 扎囊县| 宁都县| 曲靖市| 肇东市| 花垣县| 五常市| 始兴县| 灵石县| 忻城县| 榆社县| 通许县| 萨迦县| 黎城县| 莲花县|