Thanks jcl.
That problem with quit really has nothing to do with my script.

Here is a sample script which is as basic as it can get. I would expect this to run 4 times but it only runs once:

function run()
{
NumTotalCycles = 4;
if(tod() == 400) quit("its 4 am");
}

Isnīt quit supposed to call the next TotalCycle with a setup like this?