The accepted solution, of a script with a loop, works for me on a Ubuntu computer. To resolve the problem mjavu raised, which was needing a clean method to stop the script and associated task running, Ctrl-C in the terminal window works fine.