AppleScript: Press Enter Every X minutes If Terminal is Open and Application Has Been Idle for X Minutes
Why not fix it in the terminal?

I would suggest something like

while true;
  do &lt;whatever your terminal actions is&gt;;
  sleep 60; #sleep 60 seconds
done;


This will go in a continuos loop. When the program exits, it jumps to sleep 60. Which will cause it to sleep for 60 seconds and then jump back to the execution part.

Although this is not specifically what you asked for, this might be an easier way to deal with it. 

A bit closer to what you are suggesting:

 for i in {1..52};
   do &lt;your action&gt;;
   sleep 840;
 done