On Tuesday, August 16, 2016 at 11:00:11 AM UTC-7, Dave S wrote:
>
>
>
> On Tuesday, August 16, 2016 at 4:58:11 AM UTC-7, madhu nomula wrote:
>>
>> Thank you. 
>> I moved the code to Model. But could you please share me steps that 
>> how to schedule(trigger) it send emails. 
>>
>>
> I thought my suggested code was pretty clear.  sched_tasks() sets up the 
> task to run every day.  The task then checks to see if it needs to send 
> mail to everybody or just to the slow responders.
>
> If you want to schedule the task to run just twice a month, then you 
> change the "86400" to (approximately) 1209600.  I say "approximately" 
> because that value if for "every two weeks".  To do the 1st and 16th, you 
> need to figure out how much time there is from "now" to the 1st or 16th.  
> You'd use a standard Python datetime.timedelta to figure that out.  
>

As I figured out more recently (like in an answer I posted a few hours 
ago), you don't really need a time delta, you just need to figure out if 
the next run is "this month" or "next month' (1-12, not 0-11), and use 
next_run_time.
 

> You can make sched_tasks() start just the first run, and have the task 
> itself schedule itself (actually, another task instance running the same 
> code); in that case, the call to scheduler.queue_task() will set repeats=0.
>
> Please read 
> <URL:
> http://web2py.com/books/default/chapter/29/04/the-core#web2py-Scheduler>
> for details about the scheduler.
>
>
/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to