About Timers

Top  Previous  Next

A timer in the Backendless custom business logic system is a block of code with some execution schedule. A timer itself does not need to perform any scheduling work, Backendless automatically calculates the time for the next execution step of the timer, allocates computing resources and runs the code. Consider the following sample timer class:

/* global Backendless */
/**
* coolTimer timer.
* It is executed according to the schedule
*/
Backendless.ServerCode.addTimer({

  name: 'coolTimer',

  startDate: 1458592140000,

  frequency: {
    schedule: 'daily',

    repeat: {'every':1}
  },

  /**
  * @param {Object} req
  * @param {String} req.context - coderunner context
  */
  execute(req){
    //add your code here
  }
});

A timer must follow the following guidelines:

Code must use the Backendless.ServerCode.addTimer function to register a timer.
The frequency property defines the timer execution schedule.
The execute( req ) function must contain the business logic of the timer.

 


Please let us know how we can improve the documentation by leaving a comment. All technical questions should be posted to the Backendless Support forum. We do not respond to the technical questions on the documentation pages.: