You're looking at our questions archive. This question was last updated over 2 years ago.

If you're looking for help, head over to the Parse Developers Google Group or check out the tag on Stack Overflow.

Help Google Group Stack Overflow

Is there any way to schedule a Cloud Code function to be invoked periodically?

90 votes 9 answers 19.5k views over 2 years ago

Keywords: cron, background, job

Is there a way to have you guys fire off one of my Cloud Code functions on a predetermined schedule?

Something as simply as hourly, daily, weekly, monthly would be fantastic.

I think this falls in line with your mission of us not needing servers.

Example: I have a game in which a weekly tournament must have a query run to determine the winners. I currently have to run this query manually (blech! I'll forget!); or run my server which calls into the backend.

Example: I have a turn-based game in which matches that have a player that decides to not show up any more after a few days should auto-forfeit.


9 Answers

Yes! You can use Background Jobs for this purpose.

ok thanks

- Krish about 4 years ago

hope to see this feature soon..!!

- Newton Guimarães Filho about 4 years ago

Any update about this possible feature? Like, if you are working on it or have a possible date?

- Newton Guimarães Filho about 4 years ago

We generally don't post ETAs for unreleased features - if we miss that date, people will be disappointed.

- Héctor Ramos about 4 years ago

+1 on this feature.

- Juan Bermudez about 4 years ago

would be nice thanks.

- Nicolas Eypert almost 4 years ago

+1 This would be a great feature

- Jose Ines Cantu Arrambide almost 4 years ago

+1 on this

- Jess Bowers almost 4 years ago

Hector can you give me some example about where I should write my cron script to do some task periodically . You have answered that we need to set up a cronjob somewhere else to schedule some task periodically,It would be a great favour if you give example that where exactly we should write cron script.

- Rapidsoft almost 4 years ago

Our Cloud Code guide ( contains an example of how you can use curl to call a Cloud Function via the REST API. Set this up in a shell script that's called from a cronjob.

- Héctor Ramos almost 4 years ago

ashu, the code from simone (see at the bottom of the thread ) works. Mine was missing some parts. also i have a sample worker ( in python working (will post it later as Im from home now)

- Nicolas Eypert almost 4 years ago

I use for this purpose. That way I'm still "serverless". Disclosure: I don't work for them, I'm just a happy customer of both and parse.

is it ironWorker ?

- Nicolas Eypert almost 4 years ago

Yes, I use an IronWorker script written in Python. It checks an rss feed for new entries, and when one is found, sends off a push notification via Parse. The script also stores a list of processed rss entries in Parse so duplicate notifications don't get sent.

- James Richards almost 4 years ago

k thanks. looks great. I tried to use it thru javascript (node.js stuff), Althrough I'm a long time game developer, I'm really new to this web service / javascript stuff.

after browsing a bit I assembled this source (see in next comment):

I tried to launch a cloud code function (hello which prints to console).

but looks like it cannot reach the thru https, looks like a authentification issue to me.

Any idea to kickstart me ? Thanks in advance Nick

- Nicolas Eypert almost 4 years ago

var http = require('http'); var net = require('net');

var post_options = {

  host: '',
  port: '443',
  path: '/1/classes/hello',
  method: 'POST',
  headers: {
      'Content-Type': 'application/json',
      'X-Parse-Application-Id': 'MYAPPKEY',
      'X-Parse-REST-API-Key': 'MYRESTKEY'

http.request(post_options, function(res) { console.log("Got response: " + res.statusCode); }).on('error', function(e) { console.log("Got error: " + e.message); });

- Nicolas Eypert almost 4 years ago

hi, this is a complete working example of a Cloud Code function call which takes no arguments:

var https = require('https'); 
var net = require('net'); 

var headers = { 
    'Content-Type': 'application/json', 
    'X-Parse-Application-Id': '***YOUR APP ID***', 
    'X-Parse-REST-API-Key': '***YOUR REST API KEY***' 

var post_options = { 
    host: '', 
    port: '443', 
    path: '/1/functions/***YOUR FUNCTION NAME***', 
    method: 'POST', 
    headers: headers

var post_req = https.request(post_options, function(res) {
    console.log("Parse post statusCode: ", res.statusCode);

    res.on('data', function(d) {


post_req.on('error', function(e) {

sorry, I forgot to mention that this is of course this is an ironWorker example

- GoApp almost 4 years ago

thanks, now I see the part I was missing (actually sending the request). thx for helping.

- Nicolas Eypert almost 4 years ago

+1, this would really help. Otherwise, I'm forced to setup a second server to do this, and that really defeats the purpose of using Parse. It's not the end of the world, but it would be awesome-sauce to have it built-in.

Python Worker which works for me.

    import json, urllib2

print "Hello!"

in_data = {"score": "666"}
in_headers = {
          'Content-Type': "application/json",
          'X-Parse-Application-Id': "APPID",
          'X-Parse-REST-API-Key': "PARSERESTKEY"

req = urllib2.Request("", data=json.dumps(in_data), headers= in_headers)

print urllib2.urlopen(req).read()

this is something I'd love to see, also.

Example: My app needs to send a push notification to a group of users a certain number of hours before an event. I would like to have a job run hourly that would query for events about to happen and trigger the necessary notifications.

I would like to see this as well, I'm looking to do something along the same lines as Drew.

- Joe about 4 years ago


this is something that we would very much enjoy having built in



1+ On this feature. Much valuable.

I'd love to see this happen for an app I'm working on. If I could schedule a function to run some time after (say) a user uploads some data to Parse, I'd be able to build the entire back end using Parse - which would make life significantly easier for me!