开发者

Is there a Python module to get next runtime from a crontab-style time definition?

I'm writing a dashboard application and I n开发者_如何学JAVAeed a way to figure out how long an item is "valid", i.e. when should it have been superseded by a new value (it's possible to have an error such that the next value never arrives).

Since I know the schedules for the processes producing data, I can define valid as "until the next time the process should have ran".

I thought the crontab format for specifying schedules was very compact (i.e. easy to store in a database), and also easy to understand.

Finally the question: is there a Python module, that when given the current time and a crontab spec (e.g. "25 5 * * *"), returns a datetime giving the next runtime?


I ran into some issues using the code (from http://www.koders.com/python/fidA55A9DB55093A78DD26B55C606B267B2C5063A79.aspx?s=config) , and have fixed some of them. It used to break going from one month to the next. next_run now works fine, but prev_run gets stuck going from one month the previous (instead of failing it gets caught in a loop)

Here is a git repository that I've set up to continue working on it:

https://github.com/RFDaemoniac/crontab_parser

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜