I would like to schedule a feeds importer to execute at a specific time every day. Despite reading the README.txt file included with job_scheduler, I still don't quite see how to configure this. Could anyone please shed some light on this?

Comments

ShaunDychko’s picture

Solved using http://drupal.org/user/122101 with drush in a bash script executed by a cron job.

ShaunDychko’s picture

Status: Active » Closed (fixed)
killtheliterate’s picture

Status: Closed (fixed) » Active

Shaun, your link above is to a user profile, not a module. I assume you meant to reference a module?

Anyways, I'd like to achieve the exact same thing, with job_scheduler, so that my scheduled task is portable with the database.

Here's what I've got. I'd like to use the cron functionality, as it seems the most straight forward method to do something only once a day

<?php

// Building the scheduler seems to be straightforward enough, based on the readme.txt
function hook_cron_job_scheduler_info() {
  $schedulers = array();
  $schedulers['custom'] = array(
    'worker callback' => custom_job',
    'jobs' => array(
         array('crontab' => '0 0 * * *', 'periodic' => TRUE),
      )
  );
  return $schedulers;
}

// The actual job I'm doing is totally arbitrary. Shouldn't matter to job_scheduler, and it doesn't
function custom_job() {
  $job = db_truncate('custom_table')
  ->execute();

  return $job;
}
?>

The problem is that my job, which is scheduled using 'crontab', is firing on every cron run, instead of the cron specified with '0 0 * * *'. I imagine I've overlooked something rather simple, but the documentation is not terribly clear on how to do this.

I'd love some feedback on this, as it seems like the slickest and safest way to do a scheduled task. I'd rather avoid writing a custom crontab, and then hooking that. This is what job_scheduler was built for, right?

ShaunDychko’s picture

Yes, I meant to reference: http://drupal.org/node/608408, which is the drush integration for feeds. This doesn't meet your requirement of portability with the database, but if that work stalls, you can fall back on this solution, which invokes drush using a cron job (in linux) and calls the feeds importer specified by the cron job. You can then configure the various cron jobs to call each of the feeds importers at the required times.

twistor’s picture

Status: Active » Closed (fixed)

Closing this since the original poster closed it.

@killtheliterate, that sounds like a bug. Please open a new issue if you're still having problems. Thanks.