为什么没有与网站的互动,Wordpress cron没有运行?

时间:2016-08-08 06:11:33

标签: wordpress cron

我在我的WordPress插件中使用Cron作业,但是如果没有用户与WordPress网站的交互,cron就无法运行。有没有任何解决方案,我可以在5分钟后完美地运行我的cron而没有失败。

1 个答案:

答案 0 :(得分:0)

如果您在日程安排操作中使用脚本

wp_schedule_single_event(time(),'your_function_name',array('arguments'));

如果您将访问该页面,则该函数将运行。

如果要在某段时间内运行cron作业,请尝试从cpanel设置作业,并在命令提示符下写入此功能访问的完整路径。

class Example_cron {
    public function __construct() {
        $this->your_function_name();
    }
    function your_function_name() {
        // write your script here 
    }
}
$objct = new Example_cron();

设置此文件的cron路径。它将自动运行。

设置cron的命令:

php/usr/bin <file path>// example opt/lammp/htdocs/wp-content/plugins/<your plugin name>/<your fine name>

谢谢