#lisp #commonlisp #cron #clcron #sbcl
Library cl-cron
cl-cron is a simple cron like library that allows you to set up cron-like jobs and run them at predetermined times. The library has been tested on SBCL so far.
To see the documentation or download the file goto http://quickdocs.org/cl-cron/api
https://www.cliki.net/cl-cron
Installation
We suggest using quicklisp for installation.
(ql:quickload "cl-cron")
(in-package :cl-cron)
Scheduling explained
- minute (from 0 to 59)
- hour (from 0 to 23)
- day of month (from 1 to 31)
- month (from 1 to 12) (January=1)
- day of week (from 0 to 6) (Monday=0)
By default each item is equal to every, for instance :minute :every it means run the job every minute.
Examples
Execute every minute
;; the 'show-time my hypothetical job, you can define another function whatever you want.
(make-cron-job #'show-time)
Execute every hour like:
0:00
1:00
2:00
3:00
.
.
.
23:00
24:00
;; We need to define as:
(make-cron-job #'show-time
:minute 0 :hour :every)
Start, restart and stop cron
After we defined our job we need to start, or maybe stop or restart.
(cl-cron:start-cron)
(cl-cron:restart-cron)
(cl-cron:stop-cron)
