I have just started learning shell script recently, so I don\'t know much about it.
I am trying to find example of time based while loop but not having any luck.
You can use the loop command, available here, like so:
loop
$ loop './do_thing.sh' --for-duration 1h --every 5s
Which will do the your thing every five seconds for one hour.