我想在我的 php 应用程序中添加一个部分来添加/删除计划任务.
I am wanting to add a section in my php application to add / remove scheduled tasks.
类似于他们在 vBulletin 论坛中使用的内容.
Something similar to what they use in vBulletin Forum.
有人知道他们使用什么吗?他们是使用 cron 作业还是自定义完成了一些工作.
Does anyone have any ideas what they use? Are they using cron jobs or do they have something custom done.
谁能指导我如何完成类似的事情,基本上我只是想让我的脚本添加或删除 cron 作业/计划任务.
Can anyone guide me on how I can accomplish something similar to that, basically I just want my script to add or remove cron jobs / scheduled task.
我不想使用,例如 cPanel Cron 界面,我想在我的脚本中完成这个.
I don't want to use, for example the cPanel Cron interface, I would like to accomplish this from within my script.
非常感谢任何帮助.
如果你没有启用 exec()
功能,你必须依靠手动设置至少一个 cron 作业通过一些界面,然后在脚本中管理各个作业.
If you don't have the exec()
function enabled, you have to rely on manually setting at least one cron job via some interface and then managing individual jobs in your script.
我所做的就是这个
heartbeat.php
每分钟执行一次crontab
并检查是否有任何带有 time_to_process time_to_process <= NOW()
crontab
表中加载为特定行定义的类run()
方法实现了一个接口,我只调用$cronJob->run()
使其运行crontab
表处理它的重新调度heartbeat.php
which is executed every minutecrontab
and checks if there is any row (job) with time_to_process <= NOW()
crontab
tablerun()
method and I only call $cronJob->run()
to make it runcrontab
table once it finishes一个很好的例子是重置某些项目的每日视图.作业安排在 2010 年 5 月 1 日 00:00.作业运行后,它会自动安排第二天的工作.
然后,您可以在 PHP 中实现失败作业的自动重置和许多其他功能.
A good example is to reset daily views on some items.
The job is scheduled at May 1, 2010 00:00. Once the job ran, it schedules itself for the next day automatically.
You can then implement automatic reset of failed jobs and many other features from within PHP.
这篇关于在 PHP 中使用 cron 管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!