Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:45:16+00:00 2026-06-15T21:45:16+00:00

I’m trying to figure out the best way to perform a task, e.g. send

  • 0

I’m trying to figure out the best way to perform a task, e.g. send an email to a user, in the future.

My idea is to store (in a database along with users data) when the email needs to be sent, and on a daily basis check what users need emails sent, and use Meteor’s Timer functions.

// 7 hours in millisec.
Meteor.setTimeout( function() {
    Meteor.call( "sendReminderEmail", ... );
}, 2.52e+7 );

The problem that I see is having too many timers set up, and hindering performance. What is a good solution?

Edit: Basically my use case includes the user creating an event, which they set as a long term event or short term(based on days, weeks, or months), and they receive a follow-up on that event depending on the duration.

I guess I could check every hour, but that seems like a problem with equal cost. Is there a Meteor specific way to do this? Or just a better concept?

Edit2: Ok, I’ve realized that accurracy isn’t that important for my problem, so I’m thinking of setting one timer per timezone, which would send bulk emails. If the user has a long term event and their reminder is this week, than send it now. Basically it depends on duration of event and timezone of user.

So my updated question is, how do I run something on a daily basis, with my problem in mind?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:45:18+00:00Added an answer on June 15, 2026 at 9:45 pm

    Let’s say you want to execute a code at 9am today and now is 8am, you could create a timeout to match the minutes in the targeted time and then create a interval of 1 hour and at each execution check if the time is 9am, if it’s, execute.

    in this small scale example, I’m executing executeMe() when the clock shows 9 seconds:

    Live Test: http://jsbin.com/ikulok/4/edit

    <body>
    Last run: <span id="time"></span><br>
    Next execution: <span id="target"></span>
    <script type="text/javascript">
        function executeMe(){
          alert("9 seconds!");
        }
        var timeout = null;
        var interval = null;
        function timer(){
          var now = new Date();
          document.getElementById('time').innerHTML = now;
          document.getElementById('target').innerHTML = new Date(now.getTime()+ 1000);
          //console.log("timer()", now);
    
          if(now.getSeconds() == 9)
            setTimeout("executeMe();",1); // async
    
          if(interval == null)
            interval = setInterval("timer()",1000);
        }
    
        var now = new Date();
        var target = new Date(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds()+1,0);
        //console.log("now", now);
        //console.log("target", target);
        //console.log("diff", target.getTime() - now.getTime());
        document.getElementById('target').innerHTML = target;
        timeout = setTimeout("timer()", target.getTime() - now.getTime() );
      </script>
    


    If you want to run the timer() every hour instead of every second, just adjust the target and the setInterval() and of course your conditions

    Live Test: http://jsbin.com/ikulok/3/edit

    <body>
      Last run: <span id="time"></span><br>
      Next execution: <span id="target"></span>
    <script type="text/javascript">
        function executeMe(){
          alert("1:20am!");
        }
        var timeout = null;
        var interval = null;
        function timer(){
          var now = new Date();
          document.getElementById('time').innerHTML = now;
          document.getElementById('target').innerHTML = new Date(now.getTime()+ 1*60*60*1000);
          //console.log("timer()", now);
    
          if(now.getHour() == 1)
            setTimeout("executeMe();", 20*60*1000); // !!!! this will execute at 1:20am
    
          if(interval == null)
            interval = setInterval("timer()",1*60*60*1000); // !!!! repeat every hour
        }
    
        var now = new Date();
    
        // !!!! targeting next exact hour
        var target = new Date(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes()+1,0,0);
        //console.log("now", now);
        //console.log("target", target);
        //console.log("diff", target.getTime() - now.getTime());
        document.getElementById('target').innerHTML = target;
        timeout = setTimeout("timer()", target.getTime() - now.getTime() );
      </script>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.