How to run Drush as Apache

It's usually considered best practice to run Drush under the same user account that the webserver runs on. Some modules, such as XML Sitemap, Advanced Aggregator and cTools, often try to alter or generate files. If you run Drush under your own account then these files may get generated as you (and therefore become unwritable by the webserver) or, if the files were generated by the webserver, are usually unwritable by your user which can mean you get errors and being unable to delete/unlink files.

The solution is to run Drush as your webuser, usually Apache. For example:

su -s /bin/sh apache -c "/usr/bin/drush @sites cron -y"

This method also helps get around the problem/error This account is currently not available by running drush under a shell executed as Apache. On most systems, the apache user is secured to not have a shell account associated with it.