Linux shell loop in a line for while

for loop instance

query whether the tomcat process exists in 5 seconds interval, if there is out of the loop, loop at most 20 times, wait 100 seconds

for i in $(seq 1 20); do ps aux| grep tomcat | grep -v grep && break;sleep 5;done

while loop instance

query whether the tomcat process exists, if there is out of the loop, if not will wait

while true; do ps aux | grep tomcat | grep -v grep && break;sleep 5; done


Read More: