如何从 0 分钟以外的时间开始每 5 分钟运行一次 cron 作业? [英] How can I run a cron job every 5 minutes starting from a time other than 0 minutes?

查看:30
本文介绍了如何从 0 分钟以外的时间开始每 5 分钟运行一次 cron 作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想每 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 can I achieve this?

推荐答案

语法 1

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

为了将来参考,请查看此在线Cron Job Generator.

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 * * * * 2nd-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.

这篇关于如何从 0 分钟以外的时间开始每 5 分钟运行一次 cron 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆