Support for seconds in cron expressions

This commit is contained in:
Fabio Manganiello 2019-09-27 14:47:27 +02:00
parent 48e4aeb3dc
commit bcd3bf7911
1 changed files with 5 additions and 2 deletions

View File

@ -28,9 +28,12 @@ class Cronjob(Thread):
def should_run(self):
units = ('minute', 'hour', 'day', 'month', 'year')
now = datetime.datetime.fromtimestamp(time.time())
cron_units = re.split('\s+', self.cron_expression)
units = ('second', 'minute', 'hour', 'day', 'month', 'year') \
if len(cron_units) > 5 else \
('minute', 'hour', 'day', 'month', 'year')
now = datetime.datetime.fromtimestamp(time.time())
for i in range(0, len(units)):
unit = units[i]