admin管理员组

文章数量:1122832

U have a WordPress multisite install with subfolders. U'm trying to set up cron jobs. I know I can setup for each site with,

HTTP_HOST=sub.example php wp-cron.php > /dev/null

But this doesn't work for subfolders. I also know I can use wget or curl. But is there a way for doing it with php?

Edit: Not a duplicate of suggested question because I clearly mentioned that I have a subfolder install. Answers to that question mostly include wp-cli and some scripts. I don't need that.

Thanks in advance.

U have a WordPress multisite install with subfolders. U'm trying to set up cron jobs. I know I can setup for each site with,

HTTP_HOST=sub.example.com php wp-cron.php > /dev/null

But this doesn't work for subfolders. I also know I can use wget or curl. But is there a way for doing it with php?

Edit: Not a duplicate of suggested question because I clearly mentioned that I have a subfolder install. Answers to that question mostly include wp-cli and some scripts. I don't need that.

Thanks in advance.

Share Improve this question edited Apr 12, 2024 at 5:11 Jesse Nickles 7357 silver badges19 bronze badges asked Jul 16, 2018 at 7:36 Sandakelum KumaraSandakelum Kumara 11 bronze badge 3
  • 1 Possible duplicate of Running WP Cron on multisite the right way – kero Commented Jul 16, 2018 at 7:45
  • I quote I also know I can use wget or curl. But is there a way for doing it with php? – Sandakelum Kumara Commented Jul 16, 2018 at 7:58
  • 1 The beste future safe way is to use WP CLI. The second answer in the linked question also includes a PHP only example – kero Commented Jul 16, 2018 at 8:03
Add a comment  | 

1 Answer 1

Reset to default 0

I haven't tested this, but if you don't want to use WP-CLI and ONLY want to use crontab tasks, you would have to add new crontab job for each subsite, like:

curl -s https://example.com/[directory]/wp-cron.php > /dev/null 2>&1

Ref: https://vpsfix.com/7456/setup-proper-cron-jobs-wordpress-multisite-network/

You said your crons are not working for subfolders, but you don't provide any error messages or explain why it's not working... however, it should work, if you follow this.

I don't think you can avoid using wget/curl, unless you write a custom PHP script, you can see this for one example of that:

https://sabrinazeidan.com/fixing-WordPress-multisite-cron/

本文标签: Multisite subdirectory network cron jobs using only crontab and PHP