I have a real cron job setup and it seems to work. I have outlined the basics below.

The reason I ask is I don't see this method mentioned often and I'm wondering if that is because doing so is a bad idea?

I don't want to use wp-cron and disabling wp-cron on my site causes problems in other places (* even while using a real cron to run /wp-cron.php?doing_wp_cron)

Below is an example of what I'm doing:


add_action('wp_ajax_my_function', 'my_function');
add_action( 'wp_ajax_nopriv_my_function', 'my_function' );
my_function() {

Url wp-admin/admin-ajax.php?action=my_function

Cron */45 12-23 * * * wget http://www.example.com/wp-admin/admin-ajax.php?action=my_function > /dev/null

  • If you have system cron job setup, why do you need to run it with an ajax call at all?
    – s_ha_dum
    Jun 4, 2015 at 14:06
  • 1
    Basically I want a way to easily use a function, from a theme or plugin, with a cron job.
    – stemie
    Jun 4, 2015 at 14:24

1 Answer 1


You are using the system cron to trigger a function hooked into the AJAX API, not, as your title reads, using "admin-ajax.php to run a real cron job". You are doing exactly the opposite of what you wrote in the title (I'd advise editing that).

Yes, that is perfectly fine. I have advised using the same technique in fact. All you are doing is making a request to the server on an accurately timed schedule, instead of waiting for a random request from the web. It is no different from any other request to the server.


Your Answer

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

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