If you are using Drush (the command line tool for Drupal), you might come across this error on certain Linux distributions:
[user@server public_html]$ drush cc all sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which' sh: which: line 1: syntax error: unexpected end of file sh: error importing function definition for `which'
This error is caused by an incompatibility between Drush and the Linux distribution used. Drush will still be functional, however these error messages will clutter your console. In order to fix this, you can try to disable the “pcntl_exec” function in PHP. This will cause Drush to use a different execution method which doesn’t cause errors.
Change php.ini
In order to disable the “pcntl_exec” function, open up php.ini in your favorite editor. By default, php.ini is stored in /etc/php.ini.
sudo nano /etc/php.ini
Then, look for the line “disable_functions”:
; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. ; http://php.net/disable-functions disable_functions =
Change the last line and add “pcntl_exec” (if the line already contains values, simply add this new value to the end of the line):
disable_functions = pcntl_exec
Afterwards, save the file.
Execute drush statement again
Now if you run a drush command, the errors should be gone:
[user@server public_html]$ drush cc all 'all' cache was cleared.
Success!