#!/usr/bin/php null, "send_lock" => null]) as $notification) { // check tosend date if(!$notification->tosend_date || $notification->tosend_date > date('U')) continue; // get notification again from DB in case send_lock was set $notification = new Preordernotification($notification->id); if($notification->send_lock) continue; // first of all set send lock and start date $mypid = getmypid(); if(!$notification->send_start) { $notification->send_start = date("U"); } $notification->send_lock = ($mypid) ? $mypid : 1; $notification->save(); foreach($notification->getPreorders() as $preorder) { $notification->sendToPreorder($preorder); } // get notification from DB again and update send lock and finish date $notification = new Preordernotification($notification->id); $notification->send_finish = date('U'); $notification->send_lock = null; $notification->save(); }