rake cache:clear说它删除了文件,但它不是

时间:2015-05-20 23:32:28

标签: ruby-on-rails ruby unix caching rake

在cron和命令提示符下,我运行bundle exec rake cache:clear并记录我的缓存目录中的所有文件,并将其删除,但事实并非如此。 文件仍然存在,我可以使用remove命令删除它们。我已经确认它有文件权限。还有什么呢?

    About your application's environment
Ruby version              2.1.2 (x86_64-linux)
RubyGems version          2.2.2
Rack version              1.5
Rails version             4.0.9
JavaScript Runtime        Node.js (V8)
Active Record version     4.0.9
Action Pack version       4.0.9
Action Mailer version     4.0.9
Active Support version    4.0.9
Middleware                Airbrake::UserInformer, Rack::Sendfile, ActionDispatch::Static, Rack::Lock, Refraction, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffa821bb0c8>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, Airbrake::Rails::Middleware, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root          /mnt/www/ride/releases/20150519225426
Environment               development
Database adapter          mysql

用户部署在部署组中。

$ ls -l
total 18216
-rw-r--r-- 1 deploy deploy    415 May 27 16:25 03eea388375a06041afe40e5eb9585b5e4af182e.cache
-rw-r--r-- 1 deploy deploy   5424 May 27 16:25 04601c02ebf36c331e3908c4cf06771d6fab1f84.cache
-rw-r--r-- 1 deploy deploy   5416 May 27 16:25 052678a2ef02de2e241574857f17927afc4ed3fb.cache
...

这是运行cron作业的用户。以下是命令的输出:

RAILS_ENV=production bundle exec rake cache:clear --silent

***** initializing cache clear *****

***** deleting /social *****



***** deleting main cache *****

/var/www/site/tmp/cache/81d0fc6f96d4c6c957a26c932e3f2b471a56bc82.cache
/var/www/site/tmp/cache/1db90a7553f8440babe0f23932a674096184feb2.cache
/var/www/site/tmp/cache/b6d4cb2a18a5599605fec8880fc08d8604cbba07.cache

我可以以部署用户身份登录并重现此行为。执行rake任务会列出文件,但不会删除它们。使用rm命令我可以成功删除它们。

1 个答案:

答案 0 :(得分:0)

决议是使用

rake tmp:clear