You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用sidekiq-scheduler配置工作日9-18点每分钟执行的任务?

Can sidekiq-scheduler handle weekday-only scheduling from 9 AM to 6 PM, every minute?

Hey there! Great question — yes, absolutely! Sidekiq-scheduler leans on standard cron expressions, which are ideal for this kind of precise, time-bound scheduling that excludes weekends.

Here's exactly how you'd set this up in your schedule.yml file:

# Example configuration for your worker
daily_weekday_worker:
  cron: "* 9-17 * * 1-5"
  class: "YourWorkerClassName"
  queue: default
  # Optional: Set a specific timezone to avoid server timezone mismatches
  # timezone: "Asia/Shanghai"

Let's break down what this cron expression does:

  • *: Runs every minute (the first asterisk targets the minute field)
  • 9-17: Executes only between 9 AM and 5:59 PM (this covers your 9 AM to 6 PM window, since the last run at 5:59 PM is right before 6 PM)
  • *: Applies to every day of the month
  • *: Applies to every month
  • 1-5: Restricts execution to Monday through Friday (weekdays; 1 = Monday, 5 = Friday — this excludes Saturdays and Sundays)

Quick note on the 6 PM cut-off:

If you specifically need the worker to run at 6:00 PM exactly (and no later), adjust the hour range to 9-18 instead of 9-17. That way, the last execution will be at 6:00 PM, and no runs will happen after that until the next weekday morning.

Don't forget timezone!

If your server uses a different timezone than your target work hours, add the timezone key to your configuration (like the commented line above) to ensure the schedule aligns with your local time.

This setup will perfectly meet your requirement: the worker runs every minute during weekday business hours, and stays idle on weekends.

内容的提问来源于stack exchange,提问作者rwehresmann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:36:27