能否在启动命令后,在等待其返回之前继续执行。
例如:
commands
/usr/sbin/thing.sh <-- Don't wait for this to return.
more commands
在命令之间只有一个&
符号,将使每个命令独立运行,而不依赖于先前的命令是否成功。
hydrogen:tmp phyrrus9$ cat shell.sh
#! /bin/sh
echo hello
sleep 15 &
echo world
hydrogen:tmp phyrrus9$ ./shell.sh
hello
world
hydrogen:tmp phyrrus9$ ps -a
PID TTY TIME CMD
12158 ttys000 0:00.92 login -pf phyrrus9
12159 ttys000 0:00.22 -bash
12611 ttys000 0:00.00 sleep 15
12612 ttys000 0:00.01 ps -a
在命令的末尾附加“&”。已测试:
Darwin hydrogen.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
&
符号。 - pfnuesel