PHP Sleep and mysql not getting along -


i have program works in run-once mode, fails when run in background do-while-true loop includes sleep(60) delay.

if ($debug || $run_once) {check_mail($domain_mail_box, $mailboxes); exit;}      else {         {             check_mail($domain_mail_box, $mailboxes);  #       sleep 60; #       exec('sleep 60'); # wait minute after completing each run             $i=0; { $i++; } while ($i < 3000000001);         } while (true);     }     exit(0); 

actually, 3 of these attempts work fail. it's odd because have running beautifully on server/system. (both dedicated centos boxes.)

the failure mysql failure. part of script, writes log. run-once , first runs delay write mysql_stat($link): 0: uptime: 605079 / 1: threads: 2 / 2: questions: 17458285 / 3: slow queries: 0 / 4: opens: 1287520 / 5: flush tables: 1 / 6: open tables: 1024 / 7: queries per second avg: 28.852 /

but once insert delay, dreaded: 0: mysql server has gone away / mysql_stat.

any ideas what's going on?

in comment said, want use timer in order control data sync between function executions.

cron jobs more reliable approach. thing, trying implement ugly solution.

trick should use in case:

1) make cron runs every minute, , mail logic.

2) add table 'cron_locks' database name column. when cron starts, check if there row in table name.

3) if lock set, should skip cron. if lock not set - set it.

4) in end of function remove lock db.

please ask me further explanation, if not clear enough. believe correct solution problem.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -