{"id":17364322,"url":"https://github.com/arcward/crong","last_synced_at":"2026-01-23T20:41:26.024Z","repository":{"id":224438865,"uuid":"763260521","full_name":"arcward/crong","owner":"arcward","description":"Lightweight, straightforward cron parser, ticker and task scheduler for Go","archived":false,"fork":false,"pushed_at":"2024-08-27T16:38:50.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T23:42:37.364Z","etag":null,"topics":["cron","cron-expression","cron-job","cron-jobs","cronjob","cronjob-scheduler","cronjobs","crons","crontab","go","golang","scheduled-tasks","scheduler","scheduling","task-scheduler","tasks"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arcward.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":"2024-02-26T00:10:43.000Z","updated_at":"2025-01-13T16:54:33.000Z","dependencies_parsed_at":"2024-08-27T18:22:31.934Z","dependency_job_id":null,"html_url":"https://github.com/arcward/crong","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"4abe2a5262db3a758e4186b2ec87498d80bed15b"},"previous_names":["arcward/crong"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arcward/crong","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcward%2Fcrong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcward%2Fcrong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcward%2Fcrong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcward%2Fcrong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arcward","download_url":"https://codeload.github.com/arcward/crong/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcward%2Fcrong/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28699717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cron","cron-expression","cron-job","cron-jobs","cronjob","cronjob-scheduler","cronjobs","crons","crontab","go","golang","scheduled-tasks","scheduler","scheduling","task-scheduler","tasks"],"created_at":"2024-10-15T20:05:10.381Z","updated_at":"2026-01-23T20:41:26.008Z","avatar_url":"https://github.com/arcward.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crong\n\n**Cron**g: Lightweight, straightforward cron expression parser, ticker\nand task scheduler for your Golang projects.\n\n## Usage\n\nCreate a schedule from a cron expression, calculate future/past schedules:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"time\"\n\t\"github.com/arcward/crong\"\n)\n\nfunc main() {\n\tschedule, err := crong.New(\"0 0 * * *\", time.UTC)\n\tif err != nil {\n\t\tlog.Fatal(err)\n    \t}\n\t\n\t// Get the next (or most recent) scheduled time relative to the given time\n\tfmt.Println(\"Next scheduled time:\", schedule.Next(time.Now()))\n\tfmt.Println(\"Previous scheduled time:\", schedule.Prev(time.Now()))\n    \n\t// Check if the given time satisfies the schedule\n\tif schedule.Matches(time.Now()) {\n\t\tfmt.Println(\"It's time!\")\n    \t}\n}\n```\n\nCreate a ticker that sends a tick on a channel whenever the cron\nschedule fires, similar to `time.Ticker`:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"time\"\n\t\"github.com/arcward/crong\"\n)\n\nfunc main() {\n\tschedule, err := crong.New(\"@hourly\", time.UTC)\n\tif err != nil {\n\t\tlog.Fatal(err)\n    \t}\n\t\n\tticker := crong.NewTicker(context.Background(), schedule, 1 * time.Minute)\n\tdefer ticker.Stop()\n\t\n\tselect {\n\tcase t := \u003c-ticker.C:\n\t\tlog.Printf(\"%s: Tick!\", t)\n    \t}\n}\n```\n\nSchedule a function to run whenever the schedule fires:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"time\"\n\t\"github.com/arcward/crong\"\n)\n\nfunc main() {\n\tschedule, err := crong.New(\"* * * * *\", time.UTC)\n\tif err != nil {\n\t\tlog.Fatal(err)\n    \t}\n\t\n\t// MaxConcurrent=0 only allows the job to run sequentially, while\n\t// increasing TickerReceiveTimeout can accommodate potentially long-running\n\t// jobs, where you may not want the next tick to be dropped immediately.\n\t// MaxConsecutiveFailures=10 will stop executing the given function if it\n\t// returns a non-nil error ten times in a row.\n\topts := \u0026crong.ScheduledJobOptions{\n\t\tMaxConcurrent:        0,\n\t\tTickerReceiveTimeout: 30 * time.Second,\n\t\tMaxConsecutiveFailures: 10,\n\t}\n\tscheduledJob := crong.ScheduleFunc(\n\t\tcontext.Background(),\n\t\tschedule,\n\t\topts,\n\t\tfunc(t time.Time) error {\n\t\t\tlog.Printf(\"Scheduled run for %s started at %s\", t, time.Now())\n\t\t\treturn nil\n        \t},\n\t)\n\tdefer scheduledJob.Stop(context.Background())\n}\n```\n\n## Syntax\n\nSupports standard cron syntax (see https://en.wikipedia.org/wiki/Cron), as well as less standard expressions. \nFor example, `5/10 4,5 * *` means \"every 10 minutes starting at the 5th minute of the hour, for hours 4 and 5.\"\n\nDays of the week are indexed 0-6, with 0 being Sunday, and can be referenced by \nname (SUN, MON, TUE, WED, THU, FRI, SAT) or by number.\n\nMonths are indexed 1-12, and can be referenced by name \n(JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC) or by number.\n\nCron macros supported:\n\n  - `@yearly` (or `@annually`) - Run once a year, midnight, Jan. 1\n  - `@monthly` - Run once a month, midnight, first of month\n  - `@weekly` - Run once a week, midnight between Saturday and Sunday\n  - `@daily` (or `@midnight`) - Run once a day, midnight\n  - `@hourly` - Run once an hour, beginning of hour\n\nOther characters supported:\n\n  - `*`: Wildcard/Any value (ex: Every minute: `* * * * *`)\n  - `,`: Value list separator (ex: Minute 0 and 30 of every hour: `0,30 * * * *`)\n  - `-`: Range of values (ex: Minute 0-15 of every hour: `0-15 * * * *`)\n  - `/`: Step values (ex: Every 2nd minute from minute 10-20 of every hour: `10-20/2 * * * *`)\n  - `?`: No specific value (month, day of month, day of week only)\n  - `L`: Last day of month. When used, must be used alone in the day\n    field (ex: 12:30 on the last day of every month: `30 12 L * *`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcward%2Fcrong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farcward%2Fcrong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcward%2Fcrong/lists"}