Wood Chen

Unix cron rule: Run every hour from 9 to 21, Monday through Friday

0 comments397 views93 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

Yes, you can use a cron expression to set up this schedule. The format of a cron expression is:

分 时 日 月 周

For your requirements, you can use the following cron expression:

0 9-21 * * 1-5

This expression means:

  • 0: The minute field is set to 0.
  • 9-21: The hour field ranges from 9 to 21.
  • *: The day-of-month and month fields can be any value.
  • 1-5: The day-of-week field ranges from Monday to Friday.

So this cron expression runs the task every hour on the hour, from 9 through 21 inclusive, Monday through Friday.

Last updated 2024-01-14

Related posts

Comments 0