Hi, My tmp/sessions directory is getting flooded with files that AFAIK will never get removed. I could write a cron job do do this but I was wondering if that is really the most elegant and reusable way. I''d like to create something that could be extracted into a plugin. Would it be possible (and wise) to use an after_filter and backgrounddrb to remove expired sessions? Any other suggestions? Cheers, Jeroen -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jeroen Houben wrote:> Hi, > > My tmp/sessions directory is getting flooded with files that AFAIK will > never get removed. I could write a cron job do do this but I was > wondering if that is really the most elegant and reusable way. > > I''d like to create something that could be extracted into a plugin. > Would it be possible (and wise) to use an after_filter and backgrounddrb > to remove expired sessions? Any other suggestions?For what it''s worth we just use a cron job that does find /tmp/sessions -name ''ruby_sess*'' -ctime +1 -exec rm -f \{\} Not particularly beautiful but I''m not sure what there is to be gained by doing things another way Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> Jeroen Houben wrote: >> Hi, >> >> My tmp/sessions directory is getting flooded with files that AFAIK will >> never get removed. I could write a cron job do do this but I was >> wondering if that is really the most elegant and reusable way. >> >> I''d like to create something that could be extracted into a plugin. >> Would it be possible (and wise) to use an after_filter and backgrounddrb >> to remove expired sessions? Any other suggestions? > > For what it''s worth we just use a cron job that does find /tmp/sessions > -name ''ruby_sess*'' -ctime +1 -exec rm -f \{\} > Not particularly beautiful but I''m not sure what there is to be gained > by doing things another wayNot a great deal, except that you may forget to enable the cron job or you may one day decide to change your session name. Simply installing a plugin and then being able to forget about it would be nice. I don''t really want to use backgroundrb though, after some investigation it seems overkill. Think I''ll just go with your solution for now. Jeroen -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
"Frederick Cheung" wrote:> > Jeroen Houben wrote: > > Hi, > > > > My tmp/sessions directory is getting flooded with files that AFAIK will > > never get removed. I could write a cron job do do this but I was > > wondering if that is really the most elegant and reusable way. > > > > I''d like to create something that could be extracted into a plugin. > > Would it be possible (and wise) to use an after_filter and backgrounddrb > > to remove expired sessions? Any other suggestions? > > For what it''s worth we just use a cron job that does find /tmp/sessions > -name ''ruby_sess*'' -ctime +1 -exec rm -f \{\} > Not particularly beautiful but I''m not sure what there is to be gained > by doing things another way >Nice one-liner. However I can''t seem to get it to select files with -ctime or -mtime less than today (the run day). find /tmp -name ''ruby_sess*'' -maxdepth 1 -mtime n-whatever If n-whatever is less than 1 I get the full list of files. If n-whatever is >= +1 I dont get any match. I only want to remove files that are at least one day old. What am I missing? I also wrote a ruby script recently that does what I want but this is one of the scripts that is having trouble running under cron (see my post with subject ''ruby script under cron''). If anyone is interested in this script I can post it. Long --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Long wrote:> Nice one-liner. However I can''t seem to get it to select files with -ctime or -mtime > less than today (the run day). > > find /tmp -name ''ruby_sess*'' -maxdepth 1 -mtime n-whatever > > If n-whatever is less than 1 I get the full list of files. > If n-whatever is >= +1 I dont get any match. > > I only want to remove files that are at least one day old. What am I missing? > > I also wrote a ruby script recently that does what I want but this is one of > the scripts that is having trouble running under cron (see my post with subject > ''ruby script under cron''). > > If anyone is interested in this script I can post it. > > Long > >You''re thinking it backwards. -ctime +5 would be files changed 5 days ago. ''man find'' is your friend. -ctime n File’s status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jon Garvin wrote:> Long wrote: > Nice one-liner. However I can''t seem to get it to select files with -ctime or -mtime > less than today (the run day). > > find /tmp -name ''ruby_sess*'' -maxdepth 1 -mtime n-whatever > > If n-whatever is less than 1 I get the full list of files. > If n-whatever is >= +1 I dont get any match. > > I only want to remove files that are at least one day old. What am I missing? > > I also wrote a ruby script recently that does what I want but this is one of > the scripts that is having trouble running under cron (see my post with subject > ''ruby script under cron''). > > If anyone is interested in this script I can post it. > > Long > >You''re thinking it backwards. -ctime +5 would be files changed 5 days ago. ''man find'' is your friend. -ctime n File’s status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times. I do that sometimes (thinking backwards :-). I did skim through the man pages but missed the ''ago'' part. The n*24 is crucial here. The files I was testing with are less than 24 hours AGO, eventhough some were created yesterdays. It is much clearer now. Thanks Jon. Long --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---