Asterisk should not delete the call-files until they are a) fullfilled (calls where placed successfully) or b) call attempts are terminated as maxretries exceeded.
What I’m not certain about is wheter the retry-timer is internal (thus the file will not be re-readen for the next call attempt) or external in the file. Unfortunately I can’t check this at the moment. However, should the first assumption be correct (callfile is only readed once at first call attempt) than the approch should be in an other way:
MayRetries should be 0
and You should check the succesfull call within the dialplan and take the actions there according to Your requirements. To achieve this, the callfile should be a bit modified:
Channel: Local/0111234567@cfout/n
MaxRetries: 0
WaitTime: 45
Context: myContext
Extension: s
Priority: 1
SetVar: OpenAttempts=10
Archive: No
with these additional extensions (untested, just draft based on Your first posting):
[cfout]
exten => 0111234567,1,GotoIfTime(20:00-09:00|*|*|*?next)
exten => 0111234567,n,Set(RetryDelay=3600)
exten => 0111234567,n,Dial(ZAP/1/0111234567)
exten => 0111234567,n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?end)
exten => 0111234567,n(next),Set(OpenAttempts=$[${OpenAttempts}-1])
exten => 0111234567,n,GotoIf($["${OpenAttempts}" = "0"]?end)
exten => 0111234567,n,system(echo -e "Channel: Local/${EXTEN}@cfout/n\\nMaxRetries: 0\\nWaitTime: 45\\nContext: myContext\\nExtension: s\\nPriority: 1\\nSetvar: OpenAttempts=${OpenAttempts}\\nArchive:No" > /var/spool/asterisk/${EXTEN});
exten => 0111234567,n,GotoIf($["${RetryDelay}" = "3600"]?nretry)
exten => 0111234567,n,Set(day=${STRFTIME(${EPOCH},GMT,%Y%m%d)}) ; get actual date (without time)
exten => 0111234567,n,GotoIfTime(00:00-09:00|*|*|*?sameday) ; do we need to add one day ?
exten => 0111234567,n,Set(day=$[${STRPTIME(${day},GMT,%Y%m%d)+86400]} ; add one day
exten => 0111234567,n,system(touch -t ${STRFTIME($[${day}+32400],GMT,%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN}); add 9:00 hours
exten => 0111234567,n,Goto moveit
exten => 0111234567,n(sameday),Set(day=${STRPTIME(${day},GMT,%Y%m%d)} ; same day
exten => 0111234567,n,system(touch -t ${STRFTIME($[${day}+32400],GMT,%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN}); add 9:00 hours
exten => 0111234567,n,Goto moveit
exten => 0111234567,n,system(touch -t ${STRFTIME($[${EPOCH}+${RetryDelay}],%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN});
exten => 0111234567,n(nretry),system(touch -t ${STRFTIME($[${EPOCH}+${RetryDelay}],%Y%m%d%H%M.%S)} /var/spool/asterisk/${EXTEN});
exten => 0111234567,n(moveit),system(mv /var/spool/asterisk/${EXTEN} /var/spool/asterisk/outgoing/);
exten => 0111234567,n(end),Hangup