Myrddin CRON - Fix for Possible Missed Trigger Events
-
Myrddin's Cron is more or less the defacto standard for crons, however, it has a failure possibility of missing a triggering event if the time it's meant to trigger the mush happens to be lagging or, for example, the server hosting has ntpd running and skews the time where the mush is advanced a period of time.
This will fix both of those issues and guarentee a per minute trigger, and the mush will play catchup in either case.
This will only work with a codebase that handles @wait/until
Please modify your myrddin cron with these entries:
@startup mushcron=@trigger me/cron=[secs()] &CRON mushcron=@break [!$v(0)]=@pemit/list #1 %#=Must start up [name(me)] by triggering the startup.;@trigger me/cronjobs=%0; @wait/until [add(%0,60)]={@trigger me/cron=[add(%0,60)]} &CRONJOBS mushcron=@dolist [setq(8,convsecs(%0))][setq(1,extract(%q8,2,1))][setq(2,extract(%q8,3,1))][setq(3,extract(%q8,1,1))][setq(4,extract(extract(%q8,4,1),1,1,:))][setq(5,extract(convsecs(%0),2,1,:))][lattr(me/cron_time_*)]={@switch and(or(member(extract([setq(0,v(##))]%q0,1,1,|),%q1),not(strlen(extract(%q0,1,1,|)))),or(member(extract(%q0,2,1,|),%q2), not(strlen(extract(%q0,2,1,|)))),or(member(extract(%q0,3,1,|),%q3),not(strlen(extract(%q0,3,1,|)))), or(member(extract(%q0,4,1,|),%q4), not(strlen(extract(%q0,4,1,|)))),or(member(extract(%q0,5,1,|),%q5),not(strlen(extract(%q0,5,1,|)))))=1,{@pemit #1=Triggering CRON_JOB_[extract(##,3,1,_)]; @trigger me/cron_job_[extract(##,3,1,_)]=[setq(t,%0)][last(%q0,|)]}}