by Ken Task.
Guess Alain Raap that solved similar problem busy ... soooo ...
"I updated the table with laststatus = 1, start/endtime with a valid timestamp (endtime after starttime) and nextstarttime with the timestamp for the next nightrun"
from:
https://moodle.org/mod/forum/discuss.php?d=383012#p1544803
'SoS', Ken