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

发布于 2025-01-03 06:25:22 字数 1558 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伏妖词 2025-01-10 06:25:22

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

Begin the line with 0 0 * * 1,2,3,4,5 <user> <command>. The first fields are minutes and hours. In this case the command will run at midnight. The stars mean: for every day of the month, and for every month. The 1 to 5 specify the days. monday to friday. 6=saturday 0=sunday.

顾冷 2025-01-10 06:25:22

试试这个:

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

Try this:

# run every two hours at the top of the hour Monday through Friday
0 */2 * * mon-fri <command>
本王不退位尔等都是臣 2025-01-10 06:25:22

简单来说,0代表周日6周六

  • */10 * * * 1-5 - 每10分钟一次从周一到周五的一周中的某一天。
  • */10 * * * 0,6 - 周日和周六每 10 分钟一班。

To sum it up simples, 0 represents Sunday and 6 Saturday:

  • */10 * * * 1-5 - At every 10th minute on very day-of-week from Monday through Friday.
  • */10 * * * 0,6 - At every 10th minute on Sunday and Saturday.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文