Common Lisp Package: CL-CRON

README:

FUNCTION

Public

DELETE-CRON-JOB (CRON-KEY)

deletes the cron job with the corresponding hash key

GEN-LIST (START-LIST END-LIST &OPTIONAL (INCREMENT 1))

functions that returns a list of numbers starting with start-list and ending with end-list

LOG-CRON-MESSAGE (MESSAGE &OPTIONAL (TYPE error))

Simply log the message sent with type as well

MAKE-CRON-JOB (FUNCTION-SYMBOL &KEY (MINUTE EVERY) (STEP-MIN 1) (HOUR EVERY) (STEP-HOUR 1) (DAY-OF-MONTH EVERY) (STEP-DOM 1) (MONTH EVERY) (STEP-MONTH 1) (DAY-OF-WEEK EVERY) (STEP-DOW 1) (BOOT-ONLY NIL) (HASH-KEY NIL))

creates a new instance of a cron-job object and appends it to the cron-jobs-list after processing its time. Note that if you wish to use multiple values for each parameter you need to provide a list of numbers or use the gen-list function. You can not have a list of symbols when it comes to month or day-of-week. Please note that as by ANSI Common Lisp for the month variable the possible values are between 1 and 12 inclusive with January=1 and for day of week the possible values are between 0 and 6 with Monday=0. Returns the hash-key

MAX-LIST (LST)

finds the minimum element of a list

MIN-LIST (LST)

finds the minimum element of a list

RESTART-CRON

function that starts up cron but without loading the file or running any of the boot only cron jobs in the list

START-CRON

function that starts cron by first loading the cron file defined in the variable, then it runs any cron-job that has the job-only-at-boot property set to t. Finally, it starts a thread that runs cron-dispatcher

STOP-CRON

allows the stoppage of cron through the killing of the cron-dispatcher. Note that cron-dispatcher is killed only if it is sleeping otherwise we wait till the cron jobs finish. To reuse cron after calling stop-cron, you would need to recall start-cron which would go through all the steps as if cron has just booted. If you wish to prevent these actions when you restart cron then please you restart-cron.

Private

CRON-DISPATCHER

function that dispatches the jobs that are ready to be run

ELEMENTS-WITHIN-STEP (LST STEP)

function that returns a list of elements that are within a step from each other starting with the first element in the list

EXPAND-INTERNAL-LISTS (LST)

function that takes a list and returns a list but with all internal lists expanded

RUN-JOB-IF-BOOT (KEY JOB)

runs the cron-job object in a separate thread if it is a boot job

RUN-JOB-IF-TIME (KEY JOB)

runs the cron-job object in a separate thread if it is its time

TIME-TO-RUN-JOB (JOB)

checks if it is time to run the current job based on the current time

Undocumented

GET-DAYS-OF-MONTH (UNIT STEP-UNIT)

GET-DAYS-OF-WEEK (UNIT STEP-UNIT)

GET-HOURS (UNIT STEP-UNIT)

GET-MINUTES (UNIT STEP-UNIT)

GET-MONTHS (UNIT STEP-UNIT)

TIME-UNTIL-FULL-MINUTE (TIME)

MACRO

Private

Undocumented

DEF-CRON-GET-METHODS (TAG-NAME UNIT-TOTAL-LIST &OPTIONAL (ALLOWS-SYMBOLS NIL) (SYMBOL-LIST NIL) (SYMBOL-OFFSET 0))

SLOT-ACCESSOR

Private

Undocumented

JOB-@BOOT (OBJECT)

SETFJOB-@BOOT (NEW-VALUE OBJECT)

JOB-DOM (OBJECT)

SETFJOB-DOM (NEW-VALUE OBJECT)

JOB-DOW (OBJECT)

SETFJOB-DOW (NEW-VALUE OBJECT)

JOB-FUNC (OBJECT)

SETFJOB-FUNC (NEW-VALUE OBJECT)

JOB-HOUR (OBJECT)

SETFJOB-HOUR (NEW-VALUE OBJECT)

JOB-MINUTE (OBJECT)

SETFJOB-MINUTE (NEW-VALUE OBJECT)

JOB-MONTH (OBJECT)

SETFJOB-MONTH (NEW-VALUE OBJECT)

VARIABLE

Public

*CRON-LOAD-FILE*

a parameter which points to a lisp or fasl file which would be loaded once start-cron is called. The boot file should be made of as many make-cron-job calls as you like one after the other in normal s-expression fashion.

*CRON-LOG-FILE*

a parameter to set the cron file log location.

Private

*CRON-DISPATCHER-PROCESSING*

allows us to not kill the thread unless the lock can be acquired

*CRON-DISPATCHER-THREAD*

a parameter to that holds the cron-dispatcher thread

*CRON-JOBS-HASH*

contains a hash of all corn-job objects that need to be run

Undocumented

*DAY-LIST*

*MONTH-LIST*

CLASS

Private

Undocumented

CRON-JOB