FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Hourly script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Hourly script [message #173329 is a reply to message #173328] Sun, 03 April 2011 15:26 Go to previous messageGo to previous message
Mr. B-o-B is currently offline  Mr. B-o-B
Messages: 42
Registered: April 2011
Karma:
Member
On 4/3/2011 10:12 AM, Mr. B-o-B cried from the depths of the abyss:
> Jerry Stuckle cried from the depths of the abyss...
>
>> On 4/3/2011 7:03 AM, Luuk wrote:
>>> On 03-04-2011 04:00, Jerry Stuckle wrote:
>>>> And what happens when the script times out? Or it crashes? Or the
>>>> server is rebooted? Or the host kills it because it's been running for
>>>> so long? Or any of a hundred other things which can go wrong?
>>>
>>> The script that actually send a message (an email-message in this case)
>>> should of course mark the message a being send.
>>>
>>> A restart of the script should skipp all messages that already have been
>>> send...
>>>
>>>
>>>
>>
>> And how is it to know? How is it going to keep track of messages?
>
> This is not at all a problem. Assuming the OP has access to mysql(or
> another sql db), or at least the ability to create a table in the db
> then the script should create a temp table to store all the message that
> need to be sent. One of the keys should be something like
> "message_sent". When the script re-runs it should check for the temp
> table, if it exists continue with message sending otherwise (new batch
> of messages ) create a new temp table & populate with the message list.
>
> Then in a nutshell the script will query the temp table
> "SELECT * FROM temp WHERE message_sent <> 'yes'";
>
> Start iteration on the above results.
> After each message is send, update the message record to message_sent =
> 'yes' or however you want to mark it as flagged.
>
> At the start of the script note the time of the script start. Calculate
> endtime +59 minutes from start time. Also set a $messages_sent var to 0.
> Each message should ++ this var. Each iteration should check the time
> first not to exceed 60 minutes or 200 messages sent.
>
> if ($end_time >= $right_now_loop_time || $messages_sent <= 200) {
> proceed to send messages
> $messages_sent++
> update table query to mark message as sent
> }
> else{
> exit(0)
> }
>

My Bad. This should actually be && and not ||

> if ($end_time >= $right_now_loop_time || $messages_sent <= 200) {
> proceed to send messages
> $messages_sent++
> update table query to mark message as sent
> }
> else{
> exit(0)
> }

> You should also incorporate a nrow check on the table into the script.
> Once the last stored record(message) is processed(sent) the temp table
> should be dropped & exit the script.
>
> This entire process can of course be done using a file to store the
> messages on the localfile system as well (if db not available).
>
>
>> Yes, there are ways - but the op mentioned nothing about these. And if
>> the script is killed, potentially hundreds of messages could go unsent.
>
> Negative. It's not rocket science. This is not really a problem if one
> takes 25 seconds to think it over. Unfortunately you only gave it a
> couple seconds before you decided that the very easy is impossible.
>
>
>
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Firefox PHP error report
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 02:52:43 GMT 2024

Total time taken to generate the page: 0.04169 seconds