while true; do command; sleep 5; done

Category: Bash Scripting

while true; do command; sleep 5; done

Infinite loop running a command every 5 seconds

Runs a command every 5 seconds forever. Press Ctrl+C to stop. Useful for polling or monitoring.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.