Hi Doug,

You might want to try www.simpleworker.com for this, you can just schedule
your job to run every monday at 7am.

eg:

class CallbackWorker < SimpleWorker::Base

  def run
      HTTParty.get('http://myapp.heroku.com/messages/send_report')
  end
end

Then schedule it with:

worker = CallbackWorker.new
worker.schedule(:start_at=>Time.now.monday.change(:hour=>7),
:run_every=>7*24*3600)

That's it.

Travis
(disclaimer: I am with SimpleWorker)

On Thu, Mar 31, 2011 at 10:14 AM, Doug Naegele <dougnaeg...@gmail.com>wrote:

> Thanks Chris.
>
> Sorry, it didn't work.
>
> Here's my code:
>
>  if Time.now.thursday?
>     puts "Send report"
>    uri = URI.parse('http://myapp.heroku.com/messages/send_report')
>    Net::HTTP.get(uri)
>     puts " Report put is done."
>  end
>
> Here's the error output (after I ran heroku rake cron --trace)
>
> ** Invoke cron (first_time)
> ** Invoke environment (first_time)
> ** Execute environment
> ** Execute cron
> rake aborted!
> undefined method `thursday?' for Thu Mar 31 10:06:51 -0700 2011:Time
> /app/lib/tasks/cron.rake:28
>
>
> (if Time.now.thursday? is line 28)
>
> -----
>
> the following also throws an error:
>
> if Time.now == thursday
> .
> .
> .
> .
>
> (output below)
> rake aborted!
> undefined local variable or method `thursday' for main:Object
>
> ----
>
> this also throws an error:
>
> if Time.now.day == thursday
> .
> .
> .
> .
> (output below)
> rake aborted!
> undefined local variable or method `thursday' for main:Object
>
>
>
> On Mar 31, 12:32 pm, Chris Hanks <christopher.m.ha...@gmail.com>
> wrote:
> > Try: Time.now.monday?
> >
> > On Mar 31, 8:16 am, Doug Naegele <dougnaeg...@gmail.com> wrote:
> >
> >
> >
> > > Can someone help me configure Heroku Cron to only run on a certain
> > > day?
> >
> > > So, imagine I send an email report every Monday morning.  How do I
> > > write the syntax for that?
> >
> > > Something like this:
> >
> > > This one works:
> >
> > >   if Time.now.hour == 7  ##Sends report @7am, PST.
> > >     puts "Send report"
> > >     uri = URI.parse('http://myapp.heroku.com/messages/send_report')
> > >     Net::HTTP.get(uri)
> > >     puts " Report is done."
> > >   end
> >
> > > This one does not work:
> >
> > >   if Time.now == Monday  ##Sends report at the daily Heroku cron run,
> > > but only on Monday.
> > >     puts "Send report"
> > >     uri = URI.parse('http://myapp.heroku.com/messages/send_report')
> > >     Net::HTTP.get(uri)
> > >     puts " Report is done."
> > >   end
> >
> > > thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to heroku@googlegroups.com.
> To unsubscribe from this group, send email to
> heroku+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to heroku@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to