Nightly Reports
Posted: 25 February 2010 02:27 PM   [ Ignore ]
Sr. Member
RankRankRankRank
Total Posts:  132
Joined  2009-10-02

I’m looking to generate some nightly (once) reports and was thinking of using /lib/daemons/notifier.rb as the trigger

# to be placed before the sleep statement in notifier.rb

  
Time.now
  
if t.hour == && t.min 2
    
if !auto_reports_sent
      AutoReport
.send_nightly_reports(logger)
    
end
    auto_reports_sent 
true
  
else
    
auto_reports_sent false
  end 

Will that block execute ‘send_nightly_reports’ one time every night between 12:00 and 12:02

Profile
 
 
Posted: 25 February 2010 09:33 PM   [ Ignore ]   [ # 1 ]
Administrator
RankRankRankRank
Total Posts:  249
Joined  2008-12-18

That looks like it should do the trick. Are you having any problems with it?

Profile
 
 
Posted: 26 February 2010 08:07 AM   [ Ignore ]   [ # 2 ]
Sr. Member
RankRankRankRank
Total Posts:  132
Joined  2009-10-02

Haven’t tried it yet, but I worry about the strain any code that executes every 60 seconds will have on the server. I still have to generate PDFs as email attachments in the code that it calls.

Profile
 
 
Posted: 26 February 2010 08:51 AM   [ Ignore ]   [ # 3 ]
Administrator
RankRankRankRank
Total Posts:  249
Joined  2008-12-18

Unless I’m misinterpreting your code nothing will execute until midnight. In all other cases the if statement will be false.

Profile
 
 
Posted: 26 February 2010 10:44 AM   [ Ignore ]   [ # 4 ]
Sr. Member
RankRankRankRank
Total Posts:  132
Joined  2009-10-02

will AutoReport.send_nightly_reports(logger) be executed in a separate thread, or will the loop have to wait until it finishes?

Profile
 
 
Posted: 17 March 2010 09:00 AM   [ Ignore ]   [ # 5 ]
Sr. Member
RankRankRankRank
Total Posts:  132
Joined  2009-10-02

Time.now
  
if t.hour == && t.min 2
    
if !auto_reports_sent
      reports_sent 
AutoReport.send_nightly_reports(logger)
      
logger.info(reports_sent)
    
end
    auto_reports_sent 
true
  
else
    
auto_reports_sent false
  end 

I updated my code a little bit but still haven’t received an email because notifier is almost always stopped.

I log in and start notifier from the current dir and the next morning there is no email. I log back in and notifier is NOT running.

Profile
 
 
   
 
 
‹‹ Bind error      Garmin issues ››