{"id":27039665,"url":"https://github.com/meteor/meteor-synced-cron","last_synced_at":"2025-12-18T06:05:34.560Z","repository":{"id":16983253,"uuid":"19746088","full_name":"meteor/meteor-synced-cron","owner":"meteor","description":"A simple cron system for Meteor. It supports syncronizing jobs between multiple processes.","archived":false,"fork":false,"pushed_at":"2024-01-18T12:05:35.000Z","size":80,"stargazers_count":495,"open_issues_count":35,"forks_count":112,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-10-04T02:58:05.238Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"https://atmospherejs.com/littledata/synced-cron","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meteor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-13T16:07:33.000Z","updated_at":"2025-09-22T12:52:48.000Z","dependencies_parsed_at":"2022-08-28T08:51:29.351Z","dependency_job_id":"9d3228b1-6fec-41eb-a6cb-230daba42e85","html_url":"https://github.com/meteor/meteor-synced-cron","commit_stats":null,"previous_names":["meteor/meteor-synced-cron","percolatestudio/meteor-synced-cron"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/meteor/meteor-synced-cron","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fmeteor-synced-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fmeteor-synced-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fmeteor-synced-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fmeteor-synced-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meteor","download_url":"https://codeload.github.com/meteor/meteor-synced-cron/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fmeteor-synced-cron/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278406898,"owners_count":25981708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2025-04-05T03:12:45.562Z","updated_at":"2025-10-05T04:14:34.058Z","avatar_url":"https://github.com/meteor.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# percolate:synced-cron\n\nA simple cron system for [Meteor](http://meteor.com). It supports syncronizing jobs between multiple processes. In other words, if you add a job that runs every hour and your deployment consists of multiple app servers, only one of the app servers will execute the job each time (whichever tries first).\n\n## Migrated from percolate:synced-cron littledata:synced-cron\n\nSince the original creator of the project could no longer maintain it, we had to migrate the package to another organisation to allow further maintenance and updates.\n\nTo migrate you can simply run\n\n``` sh\n$ meteor remove percolate:synced-cron \u0026\u0026 meteor add littledata:synced-cron\n```\n\n## Installation\n\n``` sh\n$ meteor add littledata:synced-cron\n```\n\n## API\n\n### Basics\n\nTo write a cron job, give it a unique name, a schedule and a function to run like below. SyncedCron uses the fantastic [later.js](http://bunkat.github.io/later/) library behind the scenes. A Later.js `parse` object is passed into the schedule call that gives you a huge amount of flexibility for scheduling your jobs, see the [documentation](http://bunkat.github.io/later/parsers.html#overview).\n\n``` js\nSyncedCron.add({\n  name: 'Crunch some important numbers for the marketing department',\n  schedule: function(parser) {\n    // parser is a later.parse object\n    return parser.text('every 2 hours');\n  },\n  job: function() {\n    var numbersCrunched = CrushSomeNumbers();\n    return numbersCrunched;\n  }\n});\n```\n\nTo start processing your jobs, somewhere in your project add:\n\n``` js\nSyncedCron.start();\n```\n\n### Advanced\n\nSyncedCron uses a collection called `cronHistory` to syncronize between processes. This also serves as a useful log of when jobs ran along with their output or error. A sample item looks like:\n\n``` js\n{ _id: 'wdYLPBZp5zzbwdfYj',\n  intendedAt: Sun Apr 13 2014 17:34:00 GMT-0700 (MST),\n  finishedAt: Sun Apr 13 2014 17:34:01 GMT-0700 (MST),\n  name: 'Crunch some important numbers for the marketing department',\n  startedAt: Sun Apr 13 2014 17:34:00 GMT-0700 (MST),\n  result: '1982 numbers crunched'\n}\n```\n\nCall `SyncedCron.nextScheduledAtDate(jobName)` to find the date that the job\nreferenced by `jobName` will run next.\n\nCall `SyncedCron.remove(jobName)` to remove and stop running the job referenced by jobName.\n\nCall `SyncedCron.stop()` to remove and stop all jobs.\n\nCall `SyncedCron.pause()` to stop all jobs without removing them.  The existing jobs can be rescheduled (i.e. restarted) with `SyncedCron.start()`.\n\nTo schedule a once off (i.e not recurring) event, create a job with a schedule like this `parser.recur().on(date).fullDate();`\n\n### Configuration\n\nYou can configure SyncedCron with the `config` method. Defaults are:\n\n``` js\n  SyncedCron.config({\n    // Log job run details to console\n    log: true,\n\n    // Use a custom logger function (defaults to Meteor's logging package)\n    logger: null,\n\n    // Name of collection to use for synchronisation and logging\n    collectionName: 'cronHistory',\n\n    // Default to using localTime\n    utc: false,\n\n    /*\n      TTL in seconds for history records in collection to expire\n      NOTE: Unset to remove expiry but ensure you remove the index from\n      mongo by hand\n\n      ALSO: SyncedCron can't use the `_ensureIndex` command to modify\n      the TTL index. The best way to modify the default value of\n      `collectionTTL` is to remove the index by hand (in the mongo shell\n      run `db.cronHistory.dropIndex({startedAt: 1})`) and re-run your\n      project. SyncedCron will recreate the index with the updated TTL.\n    */\n    collectionTTL: 172800\n  });\n```\n\n### Logging\n\nSyncedCron uses Meteor's `logging` package by default. If you want to use your own logger (for sending to other consumers or similar) you can do so by configuring the `logger` option.\n\nSyncedCron expects a function as `logger`, and will pass arguments to it for you to take action on.\n\n```js\nvar MyLogger = function(opts) {\n  console.log('Level', opts.level);\n  console.log('Message', opts.message);\n  console.log('Tag', opts.tag);\n}\n\nSyncedCron.config({\n  logger: MyLogger\n});\n\nSyncedCron.add({ name: 'Test Job', ... });\nSyncedCron.start();\n```\n\nThe `opts` object passed to `MyLogger` above includes `level`, `message`, and `tag`.\n\n- `level` will be one of `info`, `warn`, `error`, `debug`.\n- `message` is something like `Scheduled \"Test Job\" next run @Fri Mar 13 2015 10:15:00 GMT+0100 (CET)`.\n- `tag` will always be `\"SyncedCron\"` (handy for filtering).\n\n\n## Caveats\n\nBeware, SyncedCron probably won't work as expected on certain shared hosting providers that shutdown app instances when they aren't receiving requests (like Heroku's free dyno tier or Meteor free galaxy).\n\n## Contributing\n\nWrite some code. Write some tests. To run the tests, do:\n\n``` sh\n$ meteor test-packages ./\n```\n\n## License\n\nMIT. (c) Percolate Studio, originally designed and built by Zoltan Olah (@zol), now community maintained.\n\nSynced Cron was developed as part of the [Verso](http://versoapp.com) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeteor%2Fmeteor-synced-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeteor%2Fmeteor-synced-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeteor%2Fmeteor-synced-cron/lists"}