Run a cron job every minute only on specific hours?(仅在特定时间每分钟运行一次 cron 作业?)
问题描述
您如何仅在特定时间每分钟运行一次 cron 作业?像这样:
How do you run a cron job every minute only on specific hours? Like so:
它只会在上午 11 点到中午 12 点、下午 4 点到下午 5 点和晚上 9 点到晚上 10 点每分钟检查一次
It will only check every minute from 11AM to 12AM, 4PM to 5PM and 9PM to 10PM
这对我来说似乎很复杂,我不知道从哪里开始.
It seems to be complicated to me I don't know where to start.
推荐答案
正确的解决方案:
* 11,16,21 * * *
因为如果您使用以前的解决方案:
Because if you use previous solution:
0-59 11-12,16-17,21-22 * * * *
作业将在 12:40 或 17:59 开始.不在上午 11 点到 12 点、下午 4 点到 5 点和晚上 9 点到 10 点的范围内.
Job will start at 12:40 or 17:59. It is not in range from 11AM to 12AM, 4PM to 5PM and 9PM to 10PM.
更新:
传统(继承自 Unix)cron 格式由五个由空格分隔的字段组成:
Traditional (inherited from Unix) cron format consists of five fields separated by white spaces:
* * * * * command to be executed
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ │
│ │ │ │ └───── day of week (0 - 6) (0 is Sunday, or use names)
│ │ │ └────────── month (1 - 12)
│ │ └─────────────── day of month (1 - 31)
│ └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)
nnCron 可以使用传统和增强"版本的 cron 格式,它有一个额外的(第 6 个)字段:年份.
nnCron can use both traditional and "enhanced" version of cron format, which has an additional (6th) field: Year.
这篇关于仅在特定时间每分钟运行一次 cron 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:仅在特定时间每分钟运行一次 cron 作业?


- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01