问题描述
我正在使用perl cron,我想制定这样的规则
I'm using perl cron, and I want to make a rule like this
从yy:yy时间开始,每隔xx分钟/小时运行一次(直到结束时间)
run every xx min/hours starting at yy:yy time (until the end of time)
如何将其放入cron字符串中? perl:cron似乎使用与常规cron相同的语法,因此常规cron字符串应该可以工作
How would I put this into a cron string? perl:cron seems to use the same syntax as regular cron so a regular cron string should work
TIA!
推荐答案
简短的答案是,根据您的需要,您将需要自己编写此代码或找到其他第三方程序包。您要求cron不做两件事:
The short answer is that you will either need to write this yourself or find a different third-party package, due to your requirements. There's two things you're asking for that cron doesn't do:
-
每X分钟运行一次。
Run every X minutes.
假设您要每40分钟运行一次,并编写此 * / 40 * * * *
。实际上,它每60分钟以1:40、2:40等运行一次。
Say you want to run every 40 minutes, and you write this */40 * * * *
. This actually runs every 60 minutes at 1:40, 2:40, etc.
在Y / Z时间开始/停止。
Start/Stop at time Y/Z.
根本没有cron语法。您可以在指定的时间使用几个cronjobs来添加/删除主要的cronjob,但这听起来很像自修改代码。考虑到复杂性(阅读:不可靠),最好找到一个不同的系统。
There's simply no cron syntax for this. You could use a couple more cronjobs to add/remove the main cronjob at the specified times, but this smells a lot like self-modifying code. Given the complexity (read: unreliability), it's probably better to find a different system.
这篇关于Perl Cron Scheduler:从x时间开始,永远每y分钟执行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!