• Resolved sbthemes

    (@sbthemes)


    Hi,

    I disabled WP Cron with define( ‘DISABLE_WP_CRON’, true ) as I am planning to manage it with real cron service.

    After disabling WP Cron I checked that WooCommerce action scheduler still working.

    As far as I know it depends on WP Cron, so why action scheduler still working even after I disabled cron? Am I missing something?

    Thanks

    • This topic was modified 4 years, 7 months ago by sbthemes.
    • This topic was modified 4 years, 7 months ago by sbthemes.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support wpnomad a11n

    (@wpnomad)

    Hi @sbthemes ,

    As far as I know it depends on WP Cron, so why action scheduler still working even after I disabled cron? Am I missing something?

    If you’re using the latest or recent versions of WooCommerce, then it includes the newer version of Action Scheduler (version 3.0). The newer version of Action Scheduler relies less on cron and uses async queue runner for processing the actions, we have details on it here: https://woocommerce.wordpress.com/2020/01/08/action-scheduler-3-0/

    I hope this helps!

    Thread Starter sbthemes

    (@sbthemes)

    Ok I get it now, I am confused with one thing though.

    WP Cron relies on website traffic which I don’t like and thats why I decided to disable default cron and wanted to handle it manually with real cron service.

    In the article link you sent, it says…

    The async queue runner initiates action processing when an admin user logs into the WordPress administration dashboard.

    Does this mean action scheduler depends on admin user login? Like only process when admin user login or refresh page on admin side?

    How can I be sure that cron is not dependent on such unreliable actions and run instantly? Like if admin doesn’t login for whole day means some important cron jobs gets delayed.

    Is there any way so I can run this manually every minute or 5 minutes to ensure it doesn’t depends on traffic or user input but its automatic?

    Thanks

    Plugin Support wpnomad a11n

    (@wpnomad)

    Hi @sbthemes ,

    Does this mean action scheduler depends on admin user login? Like only process when admin user login or refresh page on admin side?

    How can I be sure that cron is not dependent on such unreliable actions and run instantly? Like if admin doesn’t login for whole day means some important cron jobs gets delayed.

    The new action scheduler actually initiates the “queue” of actions when the admin user logs in. Once the queue has been started, all the actions within the queue would run even if the admin user doesn’t log in to the site.

    This is mentioned in the Action Scheduler 3.0 blog post link I shared previously:

    The async queue runner initiates action processing when an admin user logs into the WordPress administration dashboard. It also uses loopback requests to process multiple batches of actions in a sequence of requests so that instead of processing actions in just one request, once a queue starts processing, it will continue to process actions in a new request until there are no actions to process, or loopback limits are reached.

    I hope that gives you more insight on how the new Action Scheduler is implemented.

    Thread Starter sbthemes

    (@sbthemes)

    The new action scheduler actually initiates the “queue” of actions when the admin user logs in. Once the queue has been started, all the actions within the queue would run even if the admin user doesn’t log in to the site.

    I already read this from article and understood it but my question was let say there are 10 tasks in schedule and admin logged in so all 10 processed.

    Now admin keep account logged in for whole day and new 20 tasks added to schedule? How this will work? It will still process as user not logging in again as he is already logged in.

    Also this mean it’s not reliable as if admin doesn’t login, cron jobs will be delayed right?

    What I want to achieve is I want to disable auto processing and may be I can run every minute to ensure it always fires on time and don’t wait for admin to login or user traffic, is it possible?

    • This reply was modified 4 years, 7 months ago by sbthemes.

    Hey @sbthemes,

    The newer versions of Action Scheduler do use wp_cron less than before. It’s also true that disabling wp_cron may not prevent the queue of scheduled actions from running.

    What I hear you saying is you want something more reliable to trigger the queue than wp_cron or visits to the admin. If that’s the case you can disable wp_cron by adding this line to the wp-config.php file:

    define('DISABLE_WP_CRON', true);

    Then use either the server’s cron system or a service to call this URL:

    https://site.com/wp-cron.php?doing_wp_cron

    That will trigger the wp_cron system every time that URL is called.

    I use this on my WooCommerce Subscriptions development site. Before I switched to this method, subscriptions wouldn’t renew until I visited the site since it’s a development site it doesn’t get regular traffic. When I would open up the home page, I’d get 10 emails about subscription renewals.

    Now I get these emails within a minute of their scheduled time since wp_cron and by extension, Action Scheduler are triggered remotely. Scheduled actions actually happen when they are scheduled.

    If you want to go with a service for this, take a look at https://cron-job.org/

    Let us know if you have any questions.

    Cheers!

    Thread Starter sbthemes

    (@sbthemes)

    I don’t know if I can rely on this method.

    I already know this method but WooCommerce support says scheduler doesn’t depend on WP Cron any more so I don’t know if this method is even reliable.

    I am more confused actually, as sometimes support says its doesn’t use WP Cron, sometime says it using.

    I am sharing below what I did now.

    https://actionscheduler.org/wp-cli/

    As per this documentation I used this below plugin to disable scheduler.
    Plugin Link : https://github.com/woocommerce/action-scheduler-disable-default-runner

    And now I am running WP CLI command action-scheduler run every single minute and I think it’s working perfectly.

    I also disabled WP Cron and calling it manually every minute.

    I don’t know if this is how I should do it but in short what I did is I disabled WP Cron and Action Scheduler and now I am calling both methods manually every minute.

    Let me know if this method has any disadvantage. As all working good in my test, I don’t know if calling action-scheduler run every minute will eat lot of memory or it will just process pending jobs and closes connection (freed memory)?

    • This reply was modified 4 years, 7 months ago by sbthemes.
    • This reply was modified 4 years, 7 months ago by sbthemes.
    • This reply was modified 4 years, 7 months ago by sbthemes.

    Hey @sbthemes,

    Using the WP CLI command is a great thing to do. One of the developers of Action Scheduler often recommends that for very large sites because it such a reliable method.

    The relationship between wp_cron and Action Scheduler can be a bit confusing. So many sites have difficulty with wp_cron, especially cheap hosting, that Action Scheduler added other ways to trigger the queue. That way users without a dependable wp_cron system could still take advantage of scheduled tasks.

    It is still triggered by wp_cron though. Here’s a screenshot showing upcoming cron tasks on one of my sites.

    cron

    This is where wp_cron triggers the Action Scheduler queue. It can be triggered through admin visits too.

    Just keep on with the WP CLI method and you’ll be good to go.

    If you need help with anything else, please feel free to reach out again.

    Thanks!

    Thread Starter sbthemes

    (@sbthemes)

    Yes site I am working on has huge traffic, I am recreating new as current site has traffic but not easily scaleable, so keeping all these things in mind.

    Thank you for your input and help in this.

    • This reply was modified 4 years, 7 months ago by sbthemes.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Disabling WP Cron doesn’t stop action scheduler’ is closed to new replies.