Cisco interview question

Write a program (pseudo-code) that does some operation and prints the output to a log. But make sure the log gets printed every x seconds exactly (no matter how long the operation took).