Schedule Channel Run

Introduction

This example shows how to use the scheduler.lua module to schedule jobs (functions) to run at a specified time of day, very useful for batch processing. You can schedule multiple functions, or the same function at multiple times.

If you have other scheduling requirements please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the Schedule Channel Run channel from the Builtin: Iguana Tools repository
  • Experiment with the code to find out how it works
  • Then add the module to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a single function
  • Adapt the code to your own requirements
  • Set the polling time for the channel you are scheduling to sensible period like 5 minutes (300,000 milliseconds)
  • Use scheduler.runAt() to run your function at the desired time
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

Every time the channel runs it checks the current time against the scheduled time and the last runtime. The first time the scheduled time is exceeded the function is run (i.e., when current time is greater than the scheduled time and the last runtime is less than the scheduled time).

Note: You can vary in the frequency that the channel is run by changing the Poll Time in the From Translator Properties.

This solution also demonstrates some helpful techniques that you can apply to your own scripts:

  1. Using the simple API call iguana.setChannelStatus to customize Iguana Dashboard tooltips.
  2. Using iguana.logInfo to produce some good information whenever the batch job is invoked.
  3. Using iguana.isTest to make the script run differently in the Translator than it does in production.

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.