简体   繁体   English

手动创建的Cron作业是否出现403错误?

[英]Getting a 403 Error on manually created Cron job?

My current site is private, so it doesn't get enough consistent traffic to rely on the standard wp-cron functionality in Wordpress. 我当前的站点是私有站点,因此它没有足够的一致流量来依靠Wordpress中的标准wp-cron功能。 I've disabled the built-in cron and set up a real cron job that sends a get request every 15 minutes to https://mywebsite.com/wp-cron.php?doing_wp_cron 我已经禁用了内置的cron并设置了一个真正的cron作业,该作业每15分钟将获取请求发送到https://mywebsite.com/wp-cron.php?doing_wp_cron

For a while, this worked wonderfully. 有一阵子,这很棒。 However, I'm starting to get 403 responses on that cron job now. 但是,我现在开始在该cron工作中得到403条响应。 Sometimes it only happens once and resolves itself. 有时,它只会发生一次并自行解决。 Sometimes it gets a 403 response on every request across the span of several hours. 有时,在几个小时的跨度内,每个请求都会收到403响应。

Any ideas what could be causing this? 任何想法可能是什么原因造成的?

Also, on a related note I have two sync functions that process a large amount of data on a nightly basis at midnight and 1:00am. 另外,在相关说明中,我有两个同步功能,它们每晚在午夜和凌晨1:00处理大量数据。 I'm wondering if the cron job is failing because these processes take too long to complete. 我想知道cron作业是否失败,因为这些过程需要太长时间才能完成。 If so, is there a way that I can schedule these functions to occur regularly, but in a way that doesn't tie up the http request? 如果是这样,是否可以安排我定期执行这些功能,但是又不会占用http请求呢? For instance, calling the function asynchronously so it will carry on regardless of the completion of the function? 例如,异步调用该函数,以便无论该函数是否完成都将继续进行?

Any guidance is greatly appreciated! 任何指导,不胜感激!

AFAIK, you can run Wordpress cron jobs without going through the HTTP stack. AFAIK,您无需运行HTTP堆栈即可运行Wordpress cron作业。

After some Googling, I stumbled upon this : 经过一番谷歌搜索,我偶然发现了这一点

cd /var/www/example.com/htdocs; php wp-cron.php > /dev/null 2>&1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM