Controle a printing in loop

Is there a way to stop an infinit loop printing after a defined time, and is there a way to pause the printer for a defined period of time while printing an infinit loop.

those are both controller vs gcode issues. some controllers (klipper) have pause commands, but I am not aware of anytime time-based for pausing. you could script that with klipper using their control port, though.