如何在 cron 表达式中跳过星期六和星期日?

问题描述 投票:0回答:3

嗨,我想创建一个不包括周六和周日的 cron 表达式。

linux unix cron quartz-scheduler
3个回答
132
投票

0 0 * * 1,2,3,4,5 <user> <command>
开始行。第一个字段是分钟和小时。在这种情况下,该命令将在午夜运行。星星的意思是:每个月的每一天,每个月。 1 到 5 指定天数。星期一到星期五。 6=星期六 0=星期日。


25
投票

试试这个:

# run every two hours at the top of the hour Monday through Friday
0 */2 * * mon-fri <command>

-1
投票

总结起来很简单,0代表Sunday6 Saturday

  • */10 * * * 1-5 - 从周一到周五,每周的每一天每 10 分钟一次。
  • */10 * * * 0,6 - 周日和周六每 10 分钟一次。
© www.soinside.com 2019 - 2024. All rights reserved.