开发者

bash script kill command after timeout

开发者 https://www.devze.com 2023-02-20 09:25 出处:网络
开发者_如何学运维I have bash script that work for many files in loop. It compiles, check the result etc.
开发者_如何学运维

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

精彩评论

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