1

I need to run the following script once per 24 hours:

(1) http:domain.com/wp-cron.php?import_key=Iq_GCn7v0&import_id=36&action=trigger

the following one to run after the above, once or twice per 24 hours.

(2) http:domain.com/wp-cron.php?import_key=Iq_GCn7v0&import_id=36&action=processing

I created both cron under ACM dashboard and added the following hooks in my functions php file:

if( !wp_next_scheduled( 'myjobs_trigger' ) ) {
  wp_schedule_event( time(), 'daily', 'myjobs_trigger' );
}
add_action( 'myjobs_trigger', 'update_myjob_trigger' );
function update_myjob_trigger() {
  // do whatever you want
  wp_remote_get('http:domain.com/wp-cron.php?import_key=Iq_GCn7v0&import_id=36&action=trigger');
}//end
//Run the execution script Once every 30 minutes
if( !wp_next_scheduled( 'myjobs_process' ) ) {
  wp_schedule_event( time(), '60*30', 'myjobs_trigger' );
}
add_action( 'myjobs_process', 'update_myjob_process' );
function update_myjob_process   () {
  // do whatever you want
wp_remote_get('http:domain.com/wp-cron.php?import_key=Iq_GCn7v0&import_id=36&action=processing');
}//end

I'm missing a few things here. First I can't properly figure out how to write a function that first test the triggering cron (1) has run before running the processing cron (2). I couldn't also properly write the timing for the processing cron (2) which should be 2 times daily after the triggering cron (1) ran.

Any help will be appreciated.

  • I don't get why are you using a plugin for this – Mark Kaplun Apr 25 '16 at 13:00
  • Client said there is no help from host and I can think of any other solution. do you? – cmsdeployed Apr 25 '16 at 15:13
  • Why the wordpress core code is not enough? no plugin is likely to replace it – Mark Kaplun Apr 25 '16 at 15:15
  • 1
    Sorry, this site is not a replacement for hiring profesional help. If you must have an "helpful" answer, you should just pay someone – Mark Kaplun Apr 25 '16 at 15:59
  • 1
    @exedesign2 Really, you should use OS cron and disable WP cron in wp-config.php. There is no way that WP cron runs without a visit – OS cron can bridge that gap. There are enough sources that show you how to (both on and off site). – kaiser Apr 25 '16 at 18:22

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.