且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从 0 分钟以外的时间开始每 5 分钟运行一次 cron 作业?

更新时间:2022-12-26 17:05:17

语法 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.