接收 cron 字符串并返回下一次运行时间戳的 PHP 函数

2022-01-03 00:00:00 cron scheduling scheduled-tasks crontab php

我需要开发一个任务系统,它应该能够在不支持 crontab 的服务器上工作.

I need to develop a task system that should be able to work on servers that doesn't support crontab.

我问是否有任何现有代码可以使用 cron 字符串(例如,'0 0,12 1 */2 *' 并返回下一次计划运行的时间戳.

I'm asking if there is any existing code that can take a cron string (e.g. '0 0,12 1 */2 *' and return the timestamp of the next scheduled run.

如果找不到这样的代码,那我应该如何开始呢?

If such a code couldn't be found then how should I start with that?

推荐答案

你可以使用这个类 PHP-Parse-cron-strings-and-compute-schedules

它还会计算上次计划的运行

It'll also compute the last scheduled run

相关文章