Running a server side cron job and accessing collections / meteor user


I would like to run a cron job in my meteor app that can search thru one of my collections and check for docs that have a field data that has expired. Each doc as set date and need to see if the current date has passed. I would like to do this one a month and for each doc that has an expired date send an notification.

I looked into using -
But I’m not sure how I can access my current user and collections / docs.


Hello @almong ,
I believe your problem can be solved easily with the provided example given in the synced-cron readme documentation.

You need to write a following method in your Meteor.isServer. here’s the snippet given in the documentation.

as you said you’d require to run the program once in month , schedule should be changed accordingly. you should be able to find the appropriate for your need in here
parser docs


Hi Faysal,
Yes I have that without any issues I run into problem if I want to access Meteor.user in the cron function but I just moved it to a meteor method and it solves that issue


glad to know that your problem is solved.


and now philosophical question, what you should use?
method or global server function? :smiley:


i know this is an old topic, but if you store the userId of the user the cron is for in an object that you’re passing to the SyncedCron.add func, you can then query Meteor.users() to get that user’s information. No Meteor.method required.


@rkstar How you can pass userId as an argument to SyncedCron.add func; is it possible to call SyncedCron.add func from client side?