sharing programmer-to-programmer. please enjoy. pages are formatted for landscape tablet, laptop, or monitor.

ySCHED, scheduling grammar

greek, eunomia-horae (good order)

daily use in production

ySCHED is a shared library to implement kernihan’s scheduling grammar from the original crond implementation with a few updates and the ability to parse, validate, and test specific dates to determine appropriate run-times.

must i have done this ?! maybe not, but it opened up some great opportunities to within my khronos (cron) and horae (daily schedule) applications. i also use this parts of this in metis and others.

the purpose is to take an elegant schedule definition and make it actionable within programs.

  • minute (0-59)

  • hour (0-23)

  • day (1-31)

  • month (1-12)

  • day-of-week (1-7) my week starts on monday

  • week of year (0-53) new, useful, and optional

  • year (from 2000) new, long range, and optional

most fields have constants to clarify, * and dot always mean “all”. weekdays are two letter abbreviations, months are three. as per usual, all fields handle lists, ranges, and steps. little of this is new, it’s a well-worn mini-language.

it’s obvious this is not just a cron daemon thing, it’s useful for calendaring, task schedulers, project activities, etc. sure, it takes a little practice, but for me it simplifies so much.

the library interface is simple.

to the right is an example of my cron (khronos) validating a executable line.

ySCHED_create () converts a schedule string for library use.

ySCHED_details () returns human readable outputs for validation — the lines to the right for min, hrs, dys, mos, dow, wks, and yrs.

fancify to find troubles

i needed a quick way to identify troubles with scheduling strings. ySCHED_fancy () returns a marked up version of the raw input with highlighting, locations, and commentary.

  • all green like the bottom half means validated

  • red blocks highlighted show the trouble characters

  • to the right is some of the automatic commentary

  • also, returns the start char and length of trouble

the bottom half continues on the testing the dates and times. i entered YY.MM.DD to set configure, then the hh.mm of the current test. ySCHED_test_by_time () returned the results of match (1) or fail (0) and the commentary to the right.

one line validity periods on files

ySCHED_newfile () resets validity dates for a new file

ySCHED_valid () interprets a validity line, such as to the right, and applies it to all following lines.

testing specific times is also simple

ySCHED_config_by-date () set the year, month, and day of the test. alternatively, ySCHED_config_by_epoch () can be used.

ySCHED_test_by_time () checks by hour and minute. also, alternatively, ySCHED_test_by_epoch ().

source code is GPL3 licensed, https://github.com/heatherlyrobert/ySCHED

Previous
Previous

command line service daemon control with yJOBS

Next
Next

time-based batch automation with khronos-anileis