Is it possible to load plugin from console with core ?

While the idea that you are “developing some scrapping plugin” is sketchy and off-putting, the general question is “How do I fire code using system cron jobs?” and that is a valid question.

You don’t need to jump through hoops to load WordPress. Set up an AJAX API callback

function fire_cron_job_wpse_144051() {
  // fire your code
  die();
}
// add_action('wp_ajax_fire_cron', 'fire_cron_job_wpse_14405');
add_action('wp_ajax_nopriv_fire_cron', 'fire_cron_job_wpse_14405');

… and have your system cron job make a request to //example.com/wp-admin/admin-ajax.php?action=fire_cron. Note that fire_cron is the trailing part of the two action hooks. You can set that to whatever you like.

Leave a Comment