The Business Rules Engine



A cron is a command that tells CodaServer to execute a procedure at a certain time interval. This interval can be pretty much anything: Every Monday at 6AM. The first of each month. Biweekly.

It takes its name from a Unix command that provides the same functionality, and is extremely useful for the time-sensitive operations that seem to crop up in many business settings. Say a report needs to be run every business day at 5PM. You can write a procedure to pull together the data, and set up a cron to schedule it to run.

Crons are unlike other application objects in some ways. For one, they are not recorded in the transaction log for the application, and must be manually deployed to each environment on which they are meant to run. This is to prevent unexpected operations from running automagically once new code is deployed.

For another, managing them requires the MANAGE_CRONS permission on the application instead of the typical DEVELOPER permission that is used to handle most DDL tasks. This is because crons, while belonging to the application, are actually server processes. They should only be set up by qualified admins.

In the coda.conf configuration file, there is a line that tells the server whether it should run crons:

# Sets this server to run crons
runCron: 1
# Sets this server to not run crons
runCron: 0

For load balanced setups it is important to not have multiple CodaServers firing crons, as the procedure WILL run multiple times.


cron := CRON <cron_name> ON <application_name> . <environment> IS
        <minute> <hour> <day_of_month> <month> <day_of_week>
        [ ( [ '<string_literal>' | 
             <array_literal> ] 
             [ , ... ]* 
        ) ]?
        [ AS <username> : '<password>' ]?
environment := DEV | TEST | PROD

Defines a cron.

The time definitions follow those of the Unix CRON command, available here. If necessary the cron can run as a specified user. Sometimes a "robot" user is utilized so that it is clear in the audit history that an automated process was responsible for changing data rather than a real, live person. If no alternative user is specified, the account setting up the cron is used.

Drop Cron

drop_cron := DROP CRON <cron_name> ON <application_name> . <environment>
environment := DEV | TEST | PROD

Drops a cron permanently.