Infinite Loop in Shell Script
From Exterior Memory
This is a small example shell script that repeatedly performs the same command over and over again. In this case, killing all indexing programs for the Mac OS X SpotLight search (I use this example while traveling, to prevent laptop battery drain).
while true; do sudo killall mds mdworker; sleep 2; done;
Note that in this case, it would be better not to repeatedly kill mds, but instead just allocate it 0% CPU:
sudo killall -STOP mds mdworker