Timed Tasks (cron-like) in PHP

岁酱吖の 提交于 2019-11-26 23:08:36

问题


Is there a full featured, job scheduling package available for PHP? I'm looking for the PHP equivalent to Java's Quartz. I'm fine having things triggered externally from cron to drive the system. The functionality I'd be looking for:

  • Ability to register task (class/method) to be called at given intervals.
  • Ability to specify whether a given task can be run multiple times (potentially long running methods should not be run multiple times in certain cases).
  • All registered entries/methods could be run in parallel (jobs are backgrounded so that they do not block other timed tasks).
  • Ability to set a timeout for a given task.
  • Ability to update job control dynamically, so for instance you could disable some tasks or change their frequency without code changes.

I know it is a lot to ask, but it seems like a useful batch of features and I thought someone might have put together some portion of them.

If this or some portion of this does not already exist, any pointers to putting one together or an open source project that has a reasonably featureful implementation of some subset of these?


回答1:


A quick google turns up a few decent results:

  • http://www.bitfolge.de/pseudocron-en.htm
  • http://www.phpclasses.org/browse/package/4140.html
  • http://www.hotscripts.com/Detailed/61437.html

Really, though, if you're on any decent shared hosting package you should have access to some sort of task scheduler be it Windows' Task Scheduler or cron under *nix. I know DreamHost allows user level crontabs, at least.

HTH




回答2:


We ported Java's quartz library to PHP (https://github.com/php-quartz). The code look is as close to Java as it possible.

It has some additional features like:

  • An integration with message queues so jobs could be executed in any language.
  • There is an ability to use it as standalone service.


来源:https://stackoverflow.com/questions/318361/timed-tasks-cron-like-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!