开发者

bash script kill command after timeout

开发者_如何学运维

I have bash script that work for many files in loop. It compiles, check the result etc. Now I'd like to make a security in case of infinity loop inside of one of thouse files. something like: If it's not done after 5 min. Kill the process and gave info about that.

gcc -Wall -o "${FN}_execute" ${FN} 2> ${FN}_c_compilation.txt
./${FN}_execute $PARAM > ${FN}_c_result.txt

How to do that?


Take a look at:

http://www.bashcookbook.com/bashinfo/source/bash-4.0/examples/scripts/timeout3


You could record the start time (in seconds) and just check if the current time (in seconds) is more than 300.

But why are you writing a script to compile files manually? Doesn't make do what you want?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜