Ubuntu后臺執(zhí)行命令并獲取pid,使用pid文件殺死進(jìn)程
	1.后臺執(zhí)行command命令并獲取pid
\#后臺執(zhí)行命令并打印它的pid
    nohup command > cmd.out 2>&1 & echo $!
    nohup ping 223.5.5.5 > cmd.out 2>&1 & echo $! 
 
	\#后臺執(zhí)行命令并將它的pid保存在cmd.pid文件內(nèi)
    nohup command > cmd.out 2>&1 & echo $! > cmd.pid
    nohup ping 223.5.5.5 > cmd.out 2>&1 & echo $! > cmd.pid 
 
2.通過獲取cmd.pid文件的pid殺掉進(jìn)程 kill -9 `cat cmd.pid`
	  
版權(quán)保護(hù): 本文「Ubuntu后臺執(zhí)行命令并獲取pid,使用pid文件殺死進(jìn)程」由 云主機配置專家 原創(chuàng),轉(zhuǎn)載請保留鏈接: http://m.iqcg.cn/docs/system/296.html

