1

I want to schedule a cron job from my plugin using wp_cron but came to know that it only checks for cron only on page load. Is there any way to run a cron job even if the page is not loaded? Since I want to run this cron from my plugin on customer's server, I can't even run system cron instead of wp_cron? Any alternative to solve this problem? How does plugin like task scheduler do that?

1 Answer 1

1

Cron jobs are simply PHP scripts that are controlled by time. If the PHP file is not executed, the cron job will not be executed either.

Your option would be to set a cron job in your host's control panel, to ping a page once in a while. You can ask your host's support to do this for you, since it's different on each control panel and OS, and a bit complicated.

2
  • As I already mentioned, I want to schedule cron from my plugin which I will ship to WordPress users. I can't control other's host
    – beginner
    Feb 9, 2018 at 5:07
  • 2
    Then this is the only option. Someone has to execute your script. If it’s not the system cron job, then it’s a visitor to your wensite, triggering wp-cron in the background.
    – swissspidy
    Feb 9, 2018 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.