2017-04-17 73 views
0

我試圖殺死一個進程並啓動相同的進程。無法殺死進程並使用腳本啓動相同的進程

當我在命令行上使用pkill終止進程並使用nsd啓動服務時,它工作得很好。但是,當我在我的腳本中使用相同的命令它顯示以下錯誤:

nsd[18652]: notice: nsd starting (NSD 4.1.15)

nsd[18652]: error: can't bind udp socket: Address already in use

nsd[18652]: error: server initialization failed, nsd could not be started

error: connect ([email protected]): Connection refused

script.sh包含

pkill nsd 

nsd 

nsd-control reload 
+0

我覺得你的進程沒有被殺死。錯誤「Address already in use」表明服務器的端口已被其他進程使用 –

回答

1
pkill nsd 

# wait until nsd has disappeared 
while pgrep nsd; do sleep 1; done 

nsd 
nsd-control reload