{"id":18837969,"url":"https://github.com/nextjournal/garden-cron","last_synced_at":"2025-09-03T04:31:09.856Z","repository":{"id":206032066,"uuid":"697852395","full_name":"nextjournal/garden-cron","owner":"nextjournal","description":"Background tasks for application.garden","archived":false,"fork":false,"pushed_at":"2024-03-26T10:11:47.000Z","size":10,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-12-24T02:44:43.338Z","etag":null,"topics":["application-garden"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextjournal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-28T15:51:01.000Z","updated_at":"2024-09-22T10:41:26.000Z","dependencies_parsed_at":"2024-03-26T11:39:32.896Z","dependency_job_id":null,"html_url":"https://github.com/nextjournal/garden-cron","commit_stats":null,"previous_names":["nextjournal/garden-cron"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextjournal%2Fgarden-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextjournal%2Fgarden-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextjournal%2Fgarden-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextjournal%2Fgarden-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextjournal","download_url":"https://codeload.github.com/nextjournal/garden-cron/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231835377,"owners_count":18433710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-garden"],"created_at":"2024-11-08T02:37:20.554Z","updated_at":"2024-12-30T08:43:36.911Z","avatar_url":"https://github.com/nextjournal.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nextjournal.garden-cron\n\nThe purpose of `garden-cron` is to run a function repeatedly on a\nschedule, specified in a syntax akin to [crontab](https://crontab.guru/).\n\nThe preferred way to use `garden cron` is to use the function `defcron`\nto schedule a function periodically:\n\n```clojure {:nextjournal.clerk/code-listing true}\n(require '[nextjournal.garden-cron :refer [defcron]])\n\n(defn rooster [_time]\n  (println \"Cock-a-doodle-doo!\"))\n\n(defcron #'rooster {:hour [6] :weekday (range 1 6)})\n```\n\nThis will make the rooster wake you at 6am in the morning, but only on weekdays.\n\nMore generally, a cron expression is a map with these keys:\n\n* `:month`, integers from 1 to 12\n* `:day`, integers from 1 to 31\n* `:weekday`, integers from 1 (= Monday) to 7 (= Sunday), 0 is **not** permitted.\n* `:hour`, integers from 0 to 23\n* `:minute`, integers from 0 to 60\n* `:second`, integers from 0 to 60\n\nThe values of the map can be one of these things:\n\n* A vector, list or set of numbers, to specify the values to activate on.\n  Ranges and steps can be computed using standard Clojure `range`.\n* The value `true` or `:*` to always activate.\n\nA cron expression triggers when *all* its keys trigger, subject to the\nfollowing defaults:\n\n* A cron expression triggers on every month, unless specified.\n* A cron expression triggers on every day, unless specified.\n* A cron expression triggers on every weekday, unless specified.\n* A cron expression triggers on hour 0, unless specified.\n* A cron expression triggers on minute 0, unless specified.\n* A cron expression triggers on second 0, unless specified.\n* Additionally, if only minutes resp. only seconds are specified, it\n  triggers on any hour resp. any hour and minute, as well.\n  In doubt be more explicit.\n\nA cron expression can be disabled by calling `defcron` without a\nschedule (second argument).  This is primarily useful during development.\n\nAn optional third argument to `defcron` specifies the starting time;\nit defaults to `ZonedDateTime/now`.  This can be used to match against\na different time zone or delay scheduling until the software is started.\n\n\n## Additional features\n\nThe function `next-cron` computes the next trigger moment, given a\ncron schedule and a time.  It will always be at least 1 second after\nthe given time.\n\nThe function `cron-seq` computes an infinite list of when a cron\nschedule triggers, suitable for `chime-at`.\n\nThe function `cron-merge` merges multiple, potentially infinite, lists\nof instants in chronological order.  This can be used\nif you need more flexibility than a single cron schedule provides.\n\n\n## Dependencies\n\n`garden-cron` uses [`chime`](https://github.com/jarohen/chime)\nto do the actual execution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextjournal%2Fgarden-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextjournal%2Fgarden-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextjournal%2Fgarden-cron/lists"}