How To Write Infinite Loop in Bash
By Angsuman Chakraborty, Gaea News NetworkSunday, November 18, 2007
This is how you create an infinite loop in bash to run a piece of code perpetually at pre-defined intervals.
#!/bin/bash
while [ 1 ]
do
# Your code goes here
# Modify sleep time (in seconds) as needed below
sleep 2
done
For example I used this code to write a bash script to monitor long running mysql queries.
Merle