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).
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.
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.
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.