在后台启动进程,执行任务,然后在后台终止进程 [英] Start a process in background, do a task, then kill the process in the background
本文介绍了在后台启动进程,执行任务,然后在后台终止进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个如下所示的脚本:
I have a script that looks like this:
pushd .
nohup java -jar test/selenium-server.jar > /dev/null 2>&1 &
cd web/code/protected/tests/
phpunit functional/
popd
硒服务器需要运行以进行测试,但是在phpunit命令完成后,我想杀死正在运行的硒服务器.
The selenium servers needs to be running for the tests, however after the phpunit command finishes I'd like to kill the selenium-server that was running.
我该怎么做?
推荐答案
执行脚本后,将创建一个新的shell实例.这意味着新脚本中的jobs
不会列出在父外壳中运行的任何作业.
When the script is excecuted a new shell instance is created. Which means that the jobs
in the new script would not list any jobs running in the parent shell.
由于selenium-server
服务器是在新脚本中创建的唯一后台进程,因此可以使用以下命令将其杀死
Since the selenium-server
server is the only background process that is created in the new script it can be killed using
#The first job
kill %1
或
#The last job Same as the first one
kill %-
这篇关于在后台启动进程,执行任务,然后在后台终止进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文