linux:杀死后台任务 [英] linux: kill background task
本文介绍了linux:杀死后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 linux 中终止最后生成的后台任务?
How do I kill the last spawned background task in linux?
示例:
doSomething
doAnotherThing
doB &
doC
doD
#kill doB
????
推荐答案
bash 中有一个特殊的变量:
There's a special variable for this in bash:
kill $!
$!扩展为后台执行的最后一个进程的PID.
$! expands to the PID of the last process executed in the background.
这篇关于linux:杀死后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文