I am using a WordPress store where I am importing products and categories from external API. Procedure for each files have created in external files. Earlier I used cpanel to assign those crons like this:

/15    *  *  *  /usr/local/php56/bin/php-cli -q /home/foxypric/boomingdeal/wp-content/plugins/bigbuysync/update_data_files.php

I tried to add wp event like this but didn't work:

function sync_data_files()
register_activation_hook(__FILE__, 'datac_cron');

// Schedule Cron Job Event
function datac_cron() {
    if ( ! wp_next_scheduled( 'datac_cron' ) ) {
        wp_schedule_event( time(), 'every_fifteen_minutes', 'datac_cron' );
add_action( 'datac_cron', 'sync_data_files' );

But it also didn't work. Can anyone suggest a better method to do so. Also have tried using Wp Crontrol plugin but still no success.

  • And why do you want to do this with WP Scheduler? – Krzysiek Dróżdż Jul 9 '18 at 14:10
  • I want to run using WP scheduler. The cpanel crons doesn;t work anymore. – Rohit Kishore Jul 9 '18 at 14:31
  • And you're sure the crons didn't stop working for some other reason, such as hitting a memory limit? The same thing could be happening here. I would first try moving a simpler function into sync_data_files() just to test whether WP cron is working at all. Also keep in mind WP Crons will only run when someone is actively visiting the site, so you may have to visit your own site to make sure they fire, if you don't have a lot of traffic. – WebElaine Jul 9 '18 at 14:38
  • @WebElaine I have tried to debug WP cron by sending a test mail and that works fine. Also I have good traffic in my Woocoommerce store. – Rohit Kishore Jul 9 '18 at 14:41
  • If a simpler WP cron works, and the old server crons did work, it sounds like there is something in your script that is no longer working. Have you checked your logs to see if there are any errors or warnings? – WebElaine Jul 9 '18 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.