python 计算 crontab 下次

2020-01-08 11:24:36 浏览数 (1)

代码语言:javascript复制
python3.6 -m pip install croniter
代码语言:javascript复制
import croniter
import datetime

def run_get_next_time(sched):
    now = datetime.datetime.now()
    cron = croniter.croniter(sched, now)
    return [cron.get_next(datetime.datetime).strftime("%Y-%m-%d %H:%M")][0]

print(run_get_next_time("* * * * *"))

0 人点赞