Crontab格式化-每15分钟 [英] Crontab Formatting - every 15 minutes

查看:873
本文介绍了Crontab格式化-每15分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让每15分钟运行一次简单的crontab作业,并且在决定如何设置时间格式时遇到麻烦。

I'm trying to get a simple crontab job to run every 15 minutes and am having trouble deciding how to format the timing.

我一直在介绍的内容向下是以下内容:

What I've been putting down is the following:

15 * * * * ------------------------

我很确定这只是运行的前15分钟

I'm pretty sure this just runs the first 15 minutes of every hour.

我认为crontab允许用户指定确切的运行时间,即:

I think that crontab allows users to specify exact times to run, namely:

0, 15,30,45 * * * * -------------------------

但是,如果我想从启动那一刻起每隔15分钟运行一次crontab,(不一定是可整除的值)到15点),我该如何格式化/有可能吗?

But if I wanted to run the crontab every 15 minutes from the moment I start it, (which may not necessarily be on a value divisible by 15), how would I go about formatting that/is that possible?

推荐答案

Crontab不记得您什么时候开始(大概是您执行 crontab -e crontab文件名命令的时间)。

Crontab doesn't remember what time you "started" (presumably the time you executed the crontab -e or crontab filename command).

如果要每15分钟运行一次作业从任意时间开始,您必须指定该时间。

If you want to run the job every 15 minutes starting from an arbitrary time, you'll have to specify that time. This:

7-59/15 * * * * command

将在每小时之后的7、22、37和52分钟运行。假设您正在运行Vixie cron,这是最常见的实现。为了获得更好的可移植性,您可以使用:

will run at 7, 22, 37, and 52 minutes after each hour. That's assuming you're running Vixie cron, which is the most common implementation. For better portability, you can use:

7,22,37,52 * * * * command

请记住,前5个字段中都不能有空格;如您所问的那样, 0、15、30、45 无效。

And remember that you can't have spaces within any of the first 5 fields; 0, 15,30,45, as you had in your question, is invalid.

这篇关于Crontab格式化-每15分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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