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

问题描述

我想有一个脚本每5分钟运行一次,我们说从13:02开始,所以我可以有另一个脚本运行每5分钟,但从13:04开始,所以第二个脚本在第一个开始后两分钟运行工作。
如何实现这一点?

I would like to have a script run every 5 minutes let's say starting from 13:02 so I can have another script runs every 5 minutes but starting from 13:04 so the second script runs two minutes after the start of the first job.How Could achieve this?

推荐答案

使用:

*/5+2 * * * * 1st-script
*/5+4 * * * * 2nd-script

如需日后参考,请参阅这份线上。

For future reference take a look at this online Cron Job Generator.

由于有几个报告 + 语法在Ubuntu 14.04上不工作,这里有一个变体:

Since there are several reports that the + syntax is not working on Ubuntu 14.04, here's a variation:

2-59/5 * * * * 1st-script
4-59/5 * * * * 1st-script

这将导致第一个脚本每5分钟运行一次,每个小时开始时偏移量为2分钟,第二个脚本的偏移量为4分钟。

This will result in the 1st script to run every 5 minutes starting with an offset of 2 minutes at the beginning of each hour and the 2nd script to behave the same with an offset of 4 minutes.

这篇关于cron作业每5分钟从特定时间开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:21