{"id":19733798,"url":"https://github.com/luca-moser/chronos","last_synced_at":"2025-10-25T05:04:45.504Z","repository":{"id":57592033,"uuid":"88441102","full_name":"luca-moser/chronos","owner":"luca-moser","description":"task scheduling system (similar to cron) for Go","archived":false,"fork":false,"pushed_at":"2017-06-30T09:23:54.000Z","size":20,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-25T05:03:59.361Z","etag":null,"topics":["chronos","cron","go","golang","khronos","schedule","scheduled-jobs","scheduled-tasks"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luca-moser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-16T20:35:15.000Z","updated_at":"2017-12-25T06:47:06.000Z","dependencies_parsed_at":"2022-08-30T07:40:24.716Z","dependency_job_id":null,"html_url":"https://github.com/luca-moser/chronos","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/luca-moser/chronos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Fchronos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Fchronos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Fchronos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Fchronos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luca-moser","download_url":"https://codeload.github.com/luca-moser/chronos/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Fchronos/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280906434,"owners_count":26411415,"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","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["chronos","cron","go","golang","khronos","schedule","scheduled-jobs","scheduled-tasks"],"created_at":"2024-11-12T00:33:52.714Z","updated_at":"2025-10-25T05:04:45.489Z","avatar_url":"https://github.com/luca-moser.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Chronos - scheduled tasks for golang [![Build Status](https://travis-ci.org/luca-moser/chronos.svg?branch=master)](https://travis-ci.org/luca-moser/chronos)\n\nChronos is a library for scheduling tasks under\na given scheduling plan. It supports scheduling of monthly, weekly, daily\ntasks or at a specific date or after a given duration. It is similar to the cron service on linux.\n\n## Usage\n\nNotes:\n* The task's `Start()` function is non blocking.\n* The defined action is executed in a separate goroutine.\n\n### Schedule\n\nDaily:\n```go\n// each day on 4:30, 10:45, 12:30\nplan := NewDailySchedulingPlan([]DayTime{\n   {4, 20, 0}, \n   {10, 45, 0}, \n   {12, 30},\n})\n\ntask := NewScheduledTask(func() {\n      ...\n}, plan)\ndefer task.Stop()\n\n// start the task\ntask.Start()\n```\n\nWeekly:\n```go\n// on monday at 12, on friday twice at 9 am and 3 pm, once at sunday at 7 pm\nplan := NewWeeklySchedulingPlan([]DayTime{\n      {Day: time.Monday, At: DayTime{12, 0, 0},\n      {Day: time.Friday, At: DayTime{9, 0, 0},\n      {Day: time.Friday, At: DayTime{15, 0, 0},\n      {Day: time.Sunday, At: DayTime{19, 0, 0},\n})\n\ntask := NewScheduledTask(func() {\n      ...\n}, plan)\ndefer task.Stop()\n\n// start the task\ntask.Start()\n```\n\nMonthly:\n```go\n// on the 12th at 4:30 pm, 20th at 6 pm and 9 pm, 31th on 9 am\n// NOTE: the 31th auto. shrinks to 28, 29 (February with leap year) or 30\nplan := NewMonthlySchedulingPlan([]MonthDay{\n      {Day: 12, At: DayTime{16, 30, 0},\n      {Day: 20, At: DayTime{18, 0, 0},\n      {Day: 20, At: DayTime{21, 0, 0},\n      {Day: 31, At: DayTime{9, 0, 0},\n})\n\ntask := NewScheduledTask(func() {\n      ...\n}, plan)\ndefer task.Stop()\n\n// start the task\ntask.Start()\n```\n\n### Once \n\nat a given date:\n```go\n// once on the 29th of November at 3 pm\nplan := NewOnceAtDatePlan(time.Date(2017, time.November, 29, 15, 0, 0, 0, time.Local))\n\ntask := NewScheduledTask(func() {\n      ...\n}, plan)\ndefer task.Stop()\n\n// start the task\ntask.Start()\n```\n\nafter a given duration (essentially the same as doing time.After(d time.Duration)):\n```go\n// once after 5 seconds\nplan := NewOnceAfterDuration(time.Duration(5) * time.Second)\n\ntask := NewScheduledTask(func() {\n      ...\n}, plan)\ndefer task.Stop()\n\n// start the task\ntask.Start()\n```\n\n### Persistence\n\nUse the simple `FileStorage` to save the schedule to disk and to initialize the task back on startup.\n\n```go\nstorage := NewFileStorage(\"./\", \"schedule.json\")\nplanFromDisk, err := storage.LoadSchedule()\nif err != nil {\n    ...\n}\n\n// re-create the task with the plan loaded from disk\ntask := NewScheduledTask(func(){\n    ...\n}, planFromDisk)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluca-moser%2Fchronos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluca-moser%2Fchronos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluca-moser%2Fchronos/lists"}