How to kill a child process after a given timeout in Bash?

前端 未结 8 1899
青春惊慌失措
青春惊慌失措 2020-11-22 15:24

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

8条回答
  •  情深已故
    2020-11-22 15:34

    Assuming you have (or can easily make) a pid file for tracking the child's pid, you could then create a script that checks the modtime of the pid file and kills/respawns the process as needed. Then just put the script in crontab to run at approximately the period you need.

    Let me know if you need more details. If that doesn't sound like it'd suit your needs, what about upstart?

提交回复
热议问题