如何设置cron作业在准确的时间运行? [英] How to set a cron job to run at a exact time?

查看:374
本文介绍了如何设置cron作业在准确的时间运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cron工作,每天运行一次。但我想让它在午夜或其他时间运行。

I have a cron job that runs once a day. But I would like to make it run at midnight or other time exactly.

推荐答案

您还可以指定每个gr

You can also specify the exactly values for each gr


0 2,10,12,14,16,18,20 * * *

0 2,10,12,14,16,18,20 * * *

它代表2h00,10h00,12h00等等,直到20h00。

It stands for 2h00, 10h00, 12h00 and so on, till 20h00.

从上面的答案,我们有:

From the above answer, we have:


逗号,表示和。

The comma, ",", means "and". If you are confused by the above line, remember that spaces are the field separators, not commas.

而且从( Wikipedia page ):

*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    │
│    │    │    │    │
│    │    │    │    └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
│    │    │    └────────── month (1 - 12)
│    │    └─────────────── day of month (1 - 31)
│    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)

希望它有帮助:)

-

编辑:


  • 不要错过第一个0(零)和以下空格:it表示分零,您还可以将其设置为15(第15分钟)或类似* / 15的表达式(每分钟可由15整除,即0,15,30)

这篇关于如何设置cron作业在准确的时间运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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