So I have created script that flushes drupal's cache and it's ran in CLI.
The problem is after first use, I can't use the script again, because some classes ('SelectQueryExtender' or 'DrupalDefaultEntityController') are missing. Clearing cache via drupal admin menu (admin_menu/flush-cache) fixes it and I can rerun.
Now the question is why clearing cache from via HTTP works and from CLI doesn't?
I'm running on Drupal 7 and code can be found below:
define('DRUPAL_ROOT', '/srv/www/'); // Drupal root folder. require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // Clear cache. drupal_flush_all_caches();
EDIT: when I clear cache via drupal_flush_all_caches and later make curl call for cache clearing through apc-status.php, then even website itself gives Fatal on above mentioned classes missing.