User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:devel:reschedulecrontask [2019/06/06 12:23]
joebordes
en:devel:reschedulecrontask [2019/06/06 12:38] (current)
joebordes
Line 42: Line 42:
  
 <code PHP> <code PHP>
 +$connerror = coreBOS_Settings::​getSetting('​ExternalSyncConnectionError',​ 0);
 +$synctime = coreBOS_Settings::​getSetting('​ExternalSyncTime',​ '​02:​40'​);​ // sync daily at 2:40 am
 +
 +// try to connect
 +
 +if (connection error) {
 + if ($connerror>​=2) { // reschedule to normal time and escalate
 + coreBOS_Settings::​setSetting('​ExternalSyncConnectionError',​ 0);
 + list($hour,​ $min) = explode(':',​ $synctime);
 + $time=mktime($hour,​ $min, 0, date('​m'​),​ date('​d'​)-1,​ date('​y'​));​ // yesterday at sync time so we add 24hours
 + $cronTask->​setLastStart($time);​
 + // send email
 + } else { // reschedule in an hour
 + coreBOS_Settings::​setSetting('​ExternalSyncConnectionError',​ $connerror+1);​
 + $time=mktime(date('​h'​)+1,​ 0, 0, date('​m'​),​ date('​d'​)-1,​ date('​y'​));​ // yesterday at sync time + 1 hour so we add 24hours
 + $cronTask->​setLastStart($time);​
 + }
 +} else {
 + // do sync
 + coreBOS_Settings::​setSetting('​ExternalSyncConnectionError',​ 0);
 + list($hour,​ $min) = explode(':',​ $synctime);
 + $time=mktime($hour,​ $min, 0, date('​m'​),​ date('​d'​)-1,​ date('​y'​));​ // yesterday at sync time so we add 24hours
 + $cronTask->​setLastStart($time);​
 +}
 </​code>​ </​code>​
 +
 +<WRAP center round info 60%>
 +[[http://​blog.corebos.org/​en/​blog/​sendemail|Read here to learn how to send emails from inside coreBOS]]
 +</​WRAP>​
 +