PHP- MySQL cronjob sending mail loop repeat -
in 1 of web application, sending daily mails users using cron job function via amazon ses. cronjob run in interval of 10 mins. process like
$sql-mysql_query("select * users send_date='2013-07-13' , alert_send=0"); while($row=mysql_fetch_array($sql)) { // email id of user , compose meggage // create new amazon request , send mail // update alert_send=1 }
if loop contains more counts ie suppose 500 mails, on next 10th min, cron job start , start sending mails. @ end users mail twice or thrice accordingly.
ie. if loop contains 500 datas
cron start @ 12:00 , fetch 500 datas , send emails. suppose send mails 120 10 mins.
cron b start @ 12:10 , fetch data 120 - 500. send mail.
by result, 121 th user mails cron , cron b.
i tried of limit query count. problem cant predict when each loop ends. ie take 4,2,5,6 or 10 secs send mail.
is there way avoid duplicating ? there way kill existing cronjob , start new ?
thanks in advance
everytime when cronjob start can kill cronjob running
like name:
pkill process-name
or id:
kill 1234
also can take @ blog use php code :
http://abhinavsingh.com/blog/2009/12/how-to-use-locks-in-php-cron-jobs-to-avoid-cron-overlaps/
Comments
Post a Comment