I\'m building some software that needs a scheduling input, and I\'d really like to re-use the design of crontab because it simply works.
CrontabExpressions can be re
To output the next 25 timestamps that match the crontab you could use crontab Python module:
from datetime import datetime, timedelta
import crontab
tab = crontab.CronTab('2-59/3 1,9,22 11-26 1-6 ? 2012')
dt = datetime.now()
for _ in xrange(25):
delay = tab.next(dt) # seconds before this crontab entry can be executed.
dt += timedelta(seconds=delay)
print(dt)
2012-01-11 22:41:00
2012-01-11 22:44:00
2012-01-11 22:47:00
2012-01-11 22:50:00
2012-01-11 22:53:00
2012-01-11 22:56:00
2012-01-11 22:59:00
2012-01-12 01:02:00
2012-01-12 01:05:00
2012-01-12 01:08:00
2012-01-12 01:11:00
2012-01-12 01:14:00
2012-01-12 01:17:00
2012-01-12 01:20:00
2012-01-12 01:23:00
2012-01-12 01:26:00
2012-01-12 01:29:00
2012-01-12 01:32:00
2012-01-12 01:35:00
2012-01-12 01:38:00
2012-01-12 01:41:00
2012-01-12 01:44:00
2012-01-12 01:47:00
2012-01-12 01:50:00
2012-01-12 01:53:00
There is also python-crontab that provides crontab
module but with richer functionality (parse/generate).