shell 脚本后台运行

在终端会话中使用后台进程时一定要小心。注意,在ps命令的输出中,每一个后台进程都和
终端会话(pts/0)终端联系在一起。如果终端会话退出,那么后台进程也会随之退出。

$ ./test6.sh &
[1] 3568
$ This is Test Script #1
$ ./test7.sh &
[2] 3570
$ This is Test Script #2
$ ./test8.sh &
[3] 3573
$ And...another Test script
$ ./test9.sh &
[4] 3576
$ Then...there was one more test script
$

每次启动新作业时,Linux系统都会为其分配一个新的作业号和PID。通过ps命令,可以看到
所有脚本处于运行状态。

 #

原文地址:https://www.cnblogs.com/sea-stream/p/14061439.html