問題:
I have a bash script that launches a child process that crashes (actually, hangs) from time to time and with no apparent reason (closed source, so there isn't much I can do about it).我有一個 bash 腳本,它啓動一個子進程,該進程不時崩潰(實際上,掛起)並且沒有明顯的原因(封閉源代碼,所以我無能爲力)。 As a result, I would like to be able to launch this process for a given amount of time, and kill it if it did not return successfully after a given amount of time.因此,我希望能夠在給定的時間內啓動此進程,如果在給定的時間後沒有成功返回,則將其終止。
Is there a simple and robust way to achieve that using bash?有沒有一種簡單而強大的方法可以使用 bash 來實現這一目標?
PS: tell me if this question is better suited to serverfault or superuser. PS:告訴我這個問題是否更適合 serverfault 或超級用戶。
解決方案:
參考一: https://en.stackoom.com/question/Lef3參考二: https://stackoom.com/question/Lef3