2013-03-19 52 views
3

我有一個過程shell腳本等到過程結束

"verifyEmail" 
I run this in script as verifyEmail 0 1000 

現在怎麼辦我等到這個過程是在shell腳本上移動到下一個指令之前執行完畢?它需要超過60分鐘的verifyEmail運行

我試圖

while ! checkprocess "verifyEmail"; do ##Checkprocess is a function which returns 0 or 1 
sleep 60         ## based on process present or not 
done 
+2

超過60分鐘來運行?這是一些激烈的驗證。 「睡眠60」只能睡60 *秒*。另外,它爲什麼不同步運行?你在背景嗎? – FatalError 2013-03-19 19:23:38

回答

2

如果您運行的過程通常,你不需要做任何事情。如果你運行它異步,你只需要wait它:

verifyEmail 0 1000 
echo This will print after verifyEmail is done! 

verifyEmail 0 1000 & 
wait $! 
echo This will print after verifyEmail is done! 
+0

對不起,但他們都不起作用。我編寫腳本並運行腳本,稍後使用ps -ef命令進行檢查,仍然驗證電子郵件是否正在後臺運行 – JumpOffBox 2013-03-19 19:46:00

+0

您的verifyEmail腳本正在自我進行守護程序。它可能提供了一種禁用該機制或寫入pidfile的機制。 – 2013-03-19 20:41:54