Alternatively, there is one-liner withusing modulus:
void Update() { //if you want it loop from specific start time rather than from start of the game, //subtract said time value from Time.time argument value if(Mathf.Repeat(Time.time, execDuration + sleepDuration) < execDuration) executeFunction(); }