wordpress cron任务 [英] wordpress cron task

查看:229
本文介绍了wordpress cron任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用cron作业在Wordpress中添加一个强化任务(可以说5分钟执行时间)。

I would like to add an intensive task (lets say 5 minutes execution time) into Wordpress using cron job.

我一直在使用这个代码来添加新的cron任务

I been using this code to add new cron task inside the Wordpress system.

wp_schedule_event(time(), "interval-name", "hook-name");

我在网络的某个地方读取cron任务会在有请求的时候执行。在公共站点或管理员)。可以任何人承认这是真的吗?

I read somewhere in the net that cron task will be executed when there is request hit the Wordpress (either in the public site or the admin). Can anybody acknowledge that is true?

如果那样的情况下,我不应该把我的强化任务进入cron任务,因为它会使用户等待很长时间后任务完成。我现在该怎么办?

If that the case then I should not put my intensive task into cron task, because it will make user wait for long time after the task finished. What should I do now?

任何人都经历过这种情况?任何建议?
我想创建一个新页面由crontab执行(例如 http://example.com/wp-content/plugins/plugin-example/intensive-task.php

Anybody experienced this situation? Any suggestion? I think to create a new page to be executed by crontab (for example http://example.com/wp-content/plugins/plugin-example/intensive-task.php)

推荐答案

wordpress 文档说明,当有人访问您的网站时,它会运行,所以是的,你是正确的。只有一个用户的网页加载速度很慢,所以如果您想要避免这种情况,则由您决定。

The wordpress documentation says that it will be run when someone visits your site, so yes, you're correct. It will only be one user that gets a slow page load, so it's up to you if you want to avoid that.

如果您从常规工作中运行,没有必要使它成为您的网站上的一个网页虽然;特别是如果它是一个密集的工作,如你所说,那么这可能很容易被利用,在您的服务器上放置一个大负载。您可以轻松地从命令行运行 php 来安全地执行作业,而不会导致您网页上的任何缓慢载入时间。

If you are running it from a regular con job, there's no need to make it a page on your site though; especially if it's an intensive job, as you say, then this could easily be exploited place a large load on your server. You can easily run php from the command line to execute your job safely and without causing any slow load times on your page.

这篇关于wordpress cron任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆