Skip to content

longshotlabs/meteor-scheduled-tasks

Repository files navigation

scheduled-tasks

NOTE: This package is no longer maintained and may not work. I recommend using percolatestudio:synced-cron instead because it supports multiple app instances.

A Meteor package that provides a simple API for scheduling a function to run on the server. This is a fairly basic wrapper around laterjs and also exports the later variable.

Requires Meteor 0.9.0+

Installing

In a Meteor app directory:

$ meteor add aldeed:scheduled-tasks

Using

In server code, assuming sendHourlyEmails is a function defined elsewhere:

var schedule = later.parse.recur().on(5).minute(); // on fifth minute of every hour, every day
var hourlyEmailer = new ScheduledTask(schedule, sendHourlyEmails);

Meteor.startup(function () {
  hourlyEmailer.start();
});

You can alternatively provide a string to be text-parsed by laterjs:

var task = new ScheduledTask('at 10:15 am also at 5:15pm except on Tuesday', function () {
  console.log("Scheduled task was run.");
});
task.start();

Contributing

Anyone is welcome to contribute. Fork, make your changes, and then submit a pull request.

Support via Gittip

About

Run a function on a schedule

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published