[GH-ISSUE #894] [FEATURE REQUEST] can add opt for cron to set second #2467

Open
opened 2026-03-15 20:35:19 +03:00 by kerem · 4 comments
Owner

Originally created by @kissIce on GitHub (Jun 19, 2024).
Original GitHub issue: https://github.com/hibiken/asynq/issues/894

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
yes, my project want to set cron like The 50th second of every minute,but canot to finish it. because asynq no opt to set cron opt. it only can set min crontab express is minute,only a fixed interval second can be set。 not flexible

Describe the solution you'd like
i want asynq can add opt or func to set cron opt, such as asynq have one func to set cron.WithSeconds() cron.WithParser()

Originally created by @kissIce on GitHub (Jun 19, 2024). Original GitHub issue: https://github.com/hibiken/asynq/issues/894 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** yes, my project want to set cron like The 50th second of every minute,but canot to finish it. because asynq no opt to set cron opt. it only can set min crontab express is minute,only a fixed interval second can be set。 not flexible **Describe the solution you'd like** i want asynq can add opt or func to set cron opt, such as asynq have one func to set cron.WithSeconds() cron.WithParser()
Author
Owner

@kamikazechaser commented on GitHub (Jun 21, 2024):

like The 50th second of every minute

Well the official cronspec doens't support sub minute intervals. There are custom parsers that support this.

https://pkg.go.dev/github.com/robfig/cron/v3#hdr-Alternative_Formats

I'm not sure if we should default to this. At best, maybe allow replacing the parser.

<!-- gh-comment-id:2181952808 --> @kamikazechaser commented on GitHub (Jun 21, 2024): > like The 50th second of every minute Well the official cronspec doens't support sub minute intervals. There are custom parsers that support this. https://pkg.go.dev/github.com/robfig/cron/v3#hdr-Alternative_Formats I'm not sure if we should default to this. At best, maybe allow replacing the parser.
Author
Owner

@HelloDing2333 commented on GitHub (Jun 24, 2024):

yes

<!-- gh-comment-id:2185404676 --> @HelloDing2333 commented on GitHub (Jun 24, 2024): yes
Author
Owner

@canhlinh commented on GitHub (Mar 27, 2025):

Cron supports second by adding this cron.New(cron.WithSeconds())

Please support this feature

<!-- gh-comment-id:2756602340 --> @canhlinh commented on GitHub (Mar 27, 2025): Cron supports second by adding this `cron.New(cron.WithSeconds())` Please support this feature
Author
Owner

@canhlinh commented on GitHub (Mar 27, 2025):

@kissIce here is a workaround

	scheduler := asynq.NewScheduler(option, &asynq.SchedulerOpts{})
	cronField := reflect.ValueOf(scheduler).Elem().FieldByName("cron")
	cronValue := reflect.NewAt(cronField.Type(), unsafe.Pointer(cronField.UnsafeAddr())).Elem()
	cronValue.Set(reflect.ValueOf(cron.New(cron.WithSeconds())))
<!-- gh-comment-id:2756918648 --> @canhlinh commented on GitHub (Mar 27, 2025): @kissIce here is a workaround ``` scheduler := asynq.NewScheduler(option, &asynq.SchedulerOpts{}) cronField := reflect.ValueOf(scheduler).Elem().FieldByName("cron") cronValue := reflect.NewAt(cronField.Type(), unsafe.Pointer(cronField.UnsafeAddr())).Elem() cronValue.Set(reflect.ValueOf(cron.New(cron.WithSeconds()))) ````
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2467
No description provided.