title: Codeigniter cron job from CLI throws memcached errors
body: <p>I'm trying to set up the cron jobs for my Codigniter application, however when I run the cron, it throws me memcached errors:</p>
  
  <blockquote>
    <p>PHP Fatal error:  Call to a member function get() on a non-object in /var/www/domain.com/www/dev/system/libraries/Cache/drivers/Cache_memcached.php on line 50</p>
    
    <p>Fatal error: Call to a member function get() on a non-object in /var/www/domain.com/www/dev/system/libraries/Cache/drivers/Cache_memcached.php on line 50</p>
  </blockquote>
  
  <p>Although I have no idea why this is throwing all the time, I can't find any errors in my cron job file, nor how to solve this problem because I don't know where this is being called, I looked into my autoloaded libraries and helpers, none of them seem to be wrong.</p>
  
  <p>I also can confirm that memcached is installed, if I visit my site, memcached indeed works.</p>
  
  <p>I tried suppressing the <code>get()</code> in <code>Cached_memcached.php</code> with a <code>@</code>, but this didn't help because no output is shown (but there is supposed to be output shown).</p>
  
  <p>The command I run for the cron (user: <code>www-data</code>) is:</p>
  
  <pre><code>/usr/bin/php -q /var/www/domain.com/www/dev/index.php cron run cron 
  </code></pre>
  
  <p>I'm running Ubuntu 11.10 x86_64.</p>
  
  <p>This is my cron file:</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Cron extends CI_Controller {
  
      var $current_cron_tasks = array('cron');
  
      public function run($mode)
      {
          if($this-&gt;input-&gt;is_cli_request())
          {
              if(isset($mode) || !empty($mode))
              {
                  if(in_array($mode, $this-&gt;current_cron_tasks))
                  {
                      $this-&gt;benchmark-&gt;mark('cron_start');
  
                      if($mode == 'cron')
                      {
                          if($this-&gt;cache-&gt;memcached-&gt;get('currency_cache'))
                          {
                              if($this-&gt;cache-&gt;memcached-&gt;delete('currency_cache'))
                              {
                                  $this-&gt;load-&gt;library('convert');
                                  $this-&gt;convert-&gt;get_cache(true);
                              }
                          }
  
                          echo $mode . ' executed successfully';  
                      }
  
                      $this-&gt;benchmark-&gt;mark('cron_end');
                      $elapsed_time = $this-&gt;benchmark-&gt;elapsed_time('cron_start', 'cron_end');
  
                      echo $elapsed_time;
                  }
              }
          }
      }   
  }
  </code></pre>