Perl Cron Scheduler: start at x time, execute every y minutes forever

房东的猫 提交于 2019-12-25 04:53:35

问题


I'm using perl cron, and I want to make a rule like this

run every xx min/hours starting at yy:yy time (until the end of time)

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!


回答1:


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:

  1. Run every X minutes.

    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.

  2. Start/Stop at time Y/Z.

    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.




回答2:


You can specify intervals with a slash. Here's every 5 minutes:

*/5 * * * *

This is every 2 hours:

0 */2 * * *

You cannot give a start/ end time in cron.



来源:https://stackoverflow.com/questions/2576482/perl-cron-scheduler-start-at-x-time-execute-every-y-minutes-forever

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!