- Notifications
You must be signed in to change notification settings - Fork0
Cron written in Guile with sane schedule specification
License
igankevich/supercron
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Supercron is a scheduler (similar tocron) that runs arbitrarycommands at specified moments of time.The features that distiguish this implementation from many others are the following.
- Supercron never runs the command again unless the previous run of the samecommand has finished.
- When Supercron starts it runs all the commands that should have been run sincethe last time the daemon was alive. This feature is useful for desktop computersthat are powered off periodically.
- Supercron uses intervals with a period to specify the time points at which the commandis run. Each interval has start and end timestamp and a period. If the startor the end of the interval is omitted, then the interval is open (infinite). The commandruns at
start+period
,start+2*period
etc. until theend
of the interval. Youcan specify any number of intervals for each command. - Supercron likemcron usesGuile as a configuration language.
- Supercron uses a list of arguments to specify the command to be run and doesnot use shell by default. This is in contrast to using single string whichinevitably leads to problems with whitespace.
Here is an example of the configuration file calledexample.scm
:
(list (make <task> #:name"sleep" #:schedule (list (make <interval> #:start (time"2021-01-01T00:03:00+0300") #:period (period"1s"))) #:arguments'("/bin/sleep""10s") #:nice0));; priority adjustment
In this file we specify single task called "sleep" that runs "/bin/sleep" binarywith argument "10s". This command is launched periodically every second startingfrom "2021-01-01T00:03:00+0300" up to infinity. To run Supercron we writesupercron --verbose --period 2s example.scm
. In "verbose" mode Supercronprints a message every time the command runs or finishes, and "period"option sets global period to 2 seconds. We get the following output:
2021-06-06T20:36:10+0300 Launched process 1306: (/bin/sleep 10s)2021-06-06T20:36:12+0300 Not launching task sleep, it is already active.2021-06-06T20:36:14+0300 Not launching task sleep, it is already active.2021-06-06T20:36:16+0300 Not launching task sleep, it is already active.2021-06-06T20:36:18+0300 Not launching task sleep, it is already active.2021-06-06T20:36:20+0300 Terminated process 1306: exit code 02021-06-06T20:36:20+0300 Launched process 1322: (/bin/sleep 10s)2021-06-06T20:36:22+0300 Not launching task sleep, it is already active.2021-06-06T20:36:24+0300 Not launching task sleep, it is already active....
In order to view full schedule for the next 24 hours we usesupercron --schedule --limit 5 example.scm
:
Schedule from 2021-06-06T20:39:19+0300 to 2021-06-07T20:39:19+0300 (showing at most 5 entries):2021-06-06T20:39:19+0300 sleep2021-06-06T20:39:20+0300 sleep2021-06-06T20:39:21+0300 sleep2021-06-06T20:39:22+0300 sleep2021-06-06T20:39:23+0300 sleep
The full list of options is given bysupercron --help
.
Installsupercron.scm
to the standard location for your systemand create a wrapper script similar to the following.
#!/bin/guile3.0 --no-auto-compile!#(load"/usr/share/guile/site/3.0/supercron.scm")
About
Cron written in Guile with sane schedule specification