I've seen a lot of methods to repeat a bash command once every n seconds, but none to repeat a command for n seconds.
Is there a way to repeat a command for n seconds? So if my command takes one second to execute, it'll run ten times. If it takes two seconds, it'll run five times.
If it takes seven seconds, it would execute two times (and no more), or perhaps it would exit the script.
Right now I'm doing it by looking at the amount of time it takes for my script to execute once, and then calculating how many times I need to repeat it for it to execute for n seconds. However, this is slightly unreliable as I've found that the time required to run the script deviates a bit.