Reputation: 1124
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?
Upvotes: 2
Views: 3582
Reputation: 7864
Take a look at:
http://www.bashcookbook.com/bashinfo/source/bash-4.0/examples/scripts/timeout3
Upvotes: 4
Reputation: 8637
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?
Upvotes: 0