Custom drush command not working I have used hook_drush_command to create a new drush command. This is my custom code for creating drush command.

/**
 * Implementation of hook_drush_command().
 */
function mymodule_drush_command() {
  $items = array();
  // Name of the drush command.
  $items['list-site-users'] = array(
    'description' =&gt; 'Print the list of users in the site',
    'callback' =&gt; 'drush_get_site_users',
  );
  return $items;
}

function drush_get_site_users() {
  $query = db_select('users', 'u');
  $query-&gt;fields('u', array('name'));
  $result = $query-&gt;execute();
  while($record = $result-&gt;fetchAssoc()) {
       print_r($record['name']);
  }
}


After this I have exceuted drush cc all and drush cc drush for clearing drush. Then I have executed my custom drush command drush list-site-users command, but it is throwing the below error.


  The drush command 'list-site-users' could not be found.  Run drush
  cache-clear drush to clear the commandfile cache if you have
  installed new extensions.


My drush version is 5.10.0
Try the following:

/**
 * Implements hook_drush_command().
 */
function mymodule_drush_command() {
  $items['list-site-users'] = array(
    'description' =&gt; 'Does a database cleanup.',
    'examples' =&gt; array(
      'list-site-users' =&gt; 'Retrieve list for all users',
    ),
    'aliases' =&gt; array('lsu'),
  );
  return $items;
}

function drush_mymodule_list_site_users() {
  $query = db_select('users', 'u');
  $query-&gt;fields('u', array('name'));
  $result = $query-&gt;execute();
  while($record = $result-&gt;fetchAssoc()) {
       print_r($record['name']);
  }
}


NOTE: Make sure you write the above code in mymodule.drush.inc file of any module.
Clear the cache and your drush command should work.