• I have added a hook to functions.php and its corresponding function
    [code]
    add_action( 'fiveb_cron_daily', 'fiveb_button_cron' );
    [/code]

    The first thing fiveb_button_cron does is write to a file that is has run and then it is supposed to execute another function but it never happens. I have an admin clickable function that is almost exactly the same thing that runs perfectly whenever I click the button in admin (writes to the file and executes function).

    Using the plugin wp-control to execute the cron job with settings:
    fiveb_cron_daily None fiveb_button_cron() 2019-06-07 01:09:00 (15 hours 53 minutes) Once Daily

    I am lost on what to do next. I really need this function to run on its own at 1:09 am every morning. Any idea how to proceed would be helpful!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • I use this plugin to take over cron on my own sites to give finer control over execution. This plugin actually fires cron according to a cron task, has a bit of security wrapped around the cron task call itself, and can be fired at the specified times via the host’s cron while disabling the WordPress PsuedoCron.

    https://www.ads-software.com/plugins/wp-cron-control/

    I use an external service to trigger my cron tasks called Set Cron Job. I think it is free but I needed more so I pay a minimal fee annually to run it.

    Setting the cron with the WP Crontrol plugin you mentioned only works if there’s a visitor at the specified time you want to use. Else it just sets a cron task up to run at the next cron execution which could be hours later and might interfere with the traffic onrush of your early am visitors.

    If you can equate the cron execution to a URL then you can set a cron task to trigger just that one task via a ‘get’ without even needing either plugin.

    I have a few plugins that run from an HTTP call. My Set Cron Job account even made that easy.

    Thread Starter Shirley Studebaker

    (@shirley-studebaker)

    Wow thanks for this – there is another step I forgot to mention. At 1:10 am my hosting company has setup a cron to hit the server with /wp-cron.php that I assume is suppose to trigger that scheduled cron job function to actually run.

    How do I go about equating a cron execution to an URL or is that what I have setup with the hosting company already? or maybe I need to be more specific. What do you mean by trigger just that one task via a ‘get’…

    Thanks so much for your help. This one has me puzzled.

    Hi
    yes that is correct way:

    First, you need to disable the script to be executed every time someone loads one of your pages. To do this, open the wp-config.php file in your main WordPress folder and add the following line before the “/* That’s all, stop editing! Happy blogging. */” line:

    define(‘DISABLE_WP_CRON’, true);

    Once you do that, you need to setup a real cron job and execute the wp-cron.php file with it. You don’t want to trigger it too often – 30 minutes should be fine for most of the websites. To do this, login to your cPanel and go to the Cron jobs tool located in the Advanced section.

    Then, add the following command to be executed every 30 minutes:

    wget -q -O – https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

    You need to replace yourdomain.com with your actual domain name. The Cron jobs tool has some of the most common schedules preset.

    Thread Starter Shirley Studebaker

    (@shirley-studebaker)

    Sorry Ahir – I don’t understand what you are telling me to do. The wp-cron.php is already set to exceute at 1:10 am every morning and what is happening with wp-cron.php?doing_wp_cron. What is doing_wp_cron doing?

    Thread Starter Shirley Studebaker

    (@shirley-studebaker)

    Let me explain once again to see if I can clarify. I have a hooked function that is scheduled using wp control plugin and then I instructed the hosting company to setup an actual system cron to trigger the event one minute after schedule:

    wget -q https://www.thesageschool.org/wp-cron.php

    But the hooked function never runs. First thing it is supposed to do is write to a file and I know this works since I have that part also running from a clickable button.

    Any ideas why this does not work? THANKS!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘trying to run a cron job with wp-control’ is closed to new replies.