How to distinguish between drush and HTTP request How can I distinguish whether a function is called from drush or by a real HTTP request?
From drush.php:

function_exists('drush_main') may be used by modules to detect whether
they are being called from drush.  See http://drupal.org/node/1181308
and http://drupal.org/node/827478