本文介绍了在特定时间段内每5分钟运行一次cron的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这些时间间隔之间每5分钟执行一次cron作业:

I would like to run a cron job every 5 minutes in between these time span:


  • 星期二:8pm-10pm

  • 周三:8pm-10pm

  • 周五:8.30pm-10.30pm

  • 周六:3.30pm-5.30pm和6.30pm-8.30pm

  • 周日:3.30pm-7.30pm

  • Tuesday: 8pm - 10pm
  • Wednesday: 8pm - 10pm
  • Friday: 8.30pm - 10.30pm
  • Saturday: 3.30pm - 5.30pm and 6.30pm - 8.30pm
  • Sunday: 3.30pm - 7.30pm

我想我需要

我当前的crontab如下:

My current crontab looks like this:

COMMAND=curl -u user:password http://localhost/webapp/cache/build/openligadb >> /var/log/cron.log
# Tuesday + Wednesday 8pm - 10pm
# m     h           dom mon dow command
*/5     20-22       *   *   2,3 $COMMAND
# Friday 8.30pm - 10.30pm
# m     h           dom mon dow command
*/5+30  20-22       *   *   5   $COMMAND
# Saturday 3.30pm - 5.30pm and 6.30pm - 8.30pm
# m     h           dom mon dow command
*/5+30  15-17,18-20 *   *   6   $COMMAND
# Sunday 3.30pm - 8.30pm
# m     h           dom mon dow command
*/5+30  15-20       *   *   0   $COMMAND

I

我现在建议它每5分钟运行一次,如下所示:

I guss currently it would run every 5 minutes as follows:


  • 周二8pm-10pm

  • 周三8pm-10pm

  • 星期五8.30pm-10pm(应该是10.30pm)

  • 星期六3.30pm-5pm(应该是5.30pm)和6.30pm-8pm(应该是8.30pm)

  • 周日3.30pm-8pm(应为8.30 pm)

  • Tuesday 8pm - 10pm
  • Wednesday 8pm - 10pm
  • Friday 8.30pm - 10pm (should be 10.30pm)
  • Saturday 3.30pm - 5pm (should be 5.30pm) and 6.30pm - 8pm (should be 8.30pm)
  • Sunday 3.30pm - 8pm (should be 8.30pm)

推荐答案

如果没有适当的快捷方式,则明确列出所需时间没有什么问题:

There's nothing wrong with explicitly listing the times you need if there's no appropriate shortcut:

# Tuesday + Wednesday 8pm - 10pm
*/5     20-22       *   *   2,3 $COMMAND

# Friday 8.30pm - 10.30pm
30,35,40,45,50,55   20  *  *  5  $COMMAND
*/5                 21  *  *  5  $COMMAND
0,5,10,15,20,25,30  22  *  *  5  $COMMAND

# Saturday 3.30pm - 5.30pm and 6.30pm - 8.30pm
30,35,40,45,50,55   15,18  *  *  6  $COMMAND
*/5                 16,19  *  *  6  $COMMAND
0,5,10,15,20,25,30  17,20  *  *  6  $COMMAND

# Sunday 3.30pm - 8.30pm
30,35,40,45,50,55   15     *  *  0  $COMMAND
*/5                 16-19  *  *  0  $COMMAND
0,5,10,15,20,25,30  20     *  *  0  $COMMAND

这篇关于在特定时间段内每5分钟运行一次cron的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 17:15