How to manage rails tmp directory correctly?

After deploying the rails application in run mode, do I need to schedule a periodic cleanup of the rails tmp directory? aka: rake tmp: clear (or parts of tmp: sessions: clear, tmp: cache: clear, tmp: sockets: clear).

I know a few important changes to the rails back, it was something that needed to be done. I am currently using Rails 4.1.x. Thank.

+4
source share
1 answer

Add one or more of them to your crontab file, and this should do it for you ...

rake tmp:cache:clear              
rake tmp:clear                     
rake tmp:create                     
rake tmp:sessions:clear              
rake tmp:sockets:clear   

Keep in mind that cleanup sessions will kill all active sessions. I do not recommend. You can create a model with the name:

- :

def self.run
      CGI::Session::ActiveRecordStore::Session.
        destroy_all( ['updated_at <?', 48.hours.ago] )
  end

cron script/runner,

script/runner -e production Periodic.run
+1

All Articles