{"id":22332718,"url":"https://github.com/xgfone/gron","last_synced_at":"2025-03-26T07:22:13.043Z","repository":{"id":57513114,"uuid":"194672466","full_name":"xgfone/gron","owner":"xgfone","description":"Another job periodic runner like crontab.","archived":false,"fork":false,"pushed_at":"2021-10-17T14:16:18.000Z","size":69,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T08:43:50.828Z","etag":null,"topics":["cron","cron-job","cronjob","crontab","go-cron","go-crontab","go-job","go-task","job","job-scheduler","scheduler","task"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xgfone.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}},"created_at":"2019-07-01T12:54:07.000Z","updated_at":"2021-10-17T14:15:29.000Z","dependencies_parsed_at":"2022-08-31T22:01:25.909Z","dependency_job_id":null,"html_url":"https://github.com/xgfone/gron","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fgron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fgron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fgron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fgron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xgfone","download_url":"https://codeload.github.com/xgfone/gron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245606089,"owners_count":20643105,"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":["cron","cron-job","cronjob","crontab","go-cron","go-crontab","go-job","go-task","job","job-scheduler","scheduler","task"],"created_at":"2024-12-04T04:19:28.715Z","updated_at":"2025-03-26T07:22:13.021Z","avatar_url":"https://github.com/xgfone.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gron [![Build Status](https://github.com/xgfone/gron/actions/workflows/go.yml/badge.svg)](https://github.com/xgfone/gron/actions/workflows/go.yml) [![GoDoc](https://pkg.go.dev/badge/github.com/xgfone/gron)](https://pkg.go.dev/github.com/xgfone/gron) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://raw.githubusercontent.com/xgfone/gron/master/LICENSE)\n\nAnother job periodic runner like `crontab` supporting `Go1.7+`\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/xgfone/gron\"\n)\n\nfunc jobRunner(name string) gron.Runner {\n\treturn func(c context.Context, now time.Time) (result interface{}, err error) {\n\t\tfmt.Printf(\"Starting to run job '%s' at '%s'\\n\", name, now.Format(time.RFC3339Nano))\n\t\treturn\n\t}\n}\n\nfunc jobResultHook(result gron.JobResult) {\n\tfmt.Printf(\"End to run job '%s', cost '%s'.\\n\", result.Job.Name(), result.Cost)\n}\n\nfunc main() {\n\texe := gron.NewExecutor()\n\texe.AppendResultHooks(jobResultHook) // Add the job result hook\n\texe.Start()                          // Start the executor in the background goroutine.\n\n\t// Add jobs\n\texe.Schedule(\"job1\", gron.Every(time.Minute), jobRunner(\"job1\"))\n\texe.Schedule(\"job2\", gron.MustParseWhen(\"@every 2m\"), jobRunner(\"job2\"))\n\teveryMinuteScheduler := gron.MustParseWhen(\"*/1 * * * *\")\n\texe.ScheduleJob(gron.NewJob(\"job3\", everyMinuteScheduler, jobRunner(\"job3\")))\n\n\tgo func() {\n\t\ttime.Sleep(time.Minute * 4)\n\t\t// exe.CancelJobs(\"job1\", \"job2\", \"job3\")\n\t\texe.Stop()\n\t}()\n\n\t// Wait until the executor is stopped.\n\texe.Wait()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgfone%2Fgron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxgfone%2Fgron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgfone%2Fgron/lists"}