473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Deleting all tmp files (session,cookies,cache) in ruby

Hello,
For my ruby on rails application,i need to delete all the temporary files created in /tmp folder.If those files increases, at some point in time, my application stops working unless i delete all session files manually.Is there any way, so that i can keep on deleting those files from the folder automatically or somehow.Please help if anyone knows.Its urgent.

Thanks in advance
Jul 7 '08 #1
9 9851
acoder
16,027 Expert Mod 8TB
If you know the name of the file, just use File.delete("nameoffile.ext") For more information on input/output, see this tutorial.
Jul 7 '08 #2
If you know the name of the file, just use File.delete("nameoffile.ext") For more information on input/output, see this tutorial.
No.I think i was not clear about my question.In tmp/session folder,
ruby_sess.7e406b1b7791bd09
ruby_sess.10645ae490aa2726..
This kind of many files get created.I want clear all the files regularly.I should delete all the files in that folder.How can i do this?Hope i am clear this time.

Thanks
Jul 8 '08 #3
acoder
16,027 Expert Mod 8TB
Use the FileUtils module. Loop over the directory. If it's a file, use rm and if it's a directory use rm_f to delete the files/directories (or you could use rm with option force set to true).

Make an attempt at that and see what you can come up with.
Jul 8 '08 #4
improvcornartist
303 Expert 100+
I have no experience with FileUtils, but that may work exactly as you need. My only question about it is, will it delete current sessions? Is that a concern? If so, you could try using Dir to get all files in the tmp directory, then loop over them. Then for each file, you can check its last modified time (using File.stat) to determine if you want to delete it. I've never used this for the tmp directory, but it works for other situations.
Jul 8 '08 #5
acoder
16,027 Expert Mod 8TB
Good point. Always a good idea to look at the wider picture.
Jul 8 '08 #6
Hello,

Good day ! :)

I am also in a same position as you.I need to delete all my session files from /tmp directory.Did you found any alternative for that.

Please help me in this issue.I would be Great to you if you can help me in resolving this.

Cheers,
Rajesh
Aug 2 '08 #7
acoder
16,027 Expert Mod 8TB
Did you try the suggestions above?
Aug 2 '08 #8
Yes I tried a bit But No idea at all.
Aug 5 '08 #9
acoder
16,027 Expert Mod 8TB
What did you try? Both suggestions should work. Is it the looping part that's causing you problems. Show your code.
Aug 5 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tom | last post by:
Hi, I would like to use the standard PHP sessions and I understand they rely on the target web browser to support session cookies. I have tried the following code: <? session_start(); if...
2
by: Theo | last post by:
Hi all Looked around on the net for an answer to a question and havent found it yet. Im learning to use sessions for authentication. So far so good. Learned how to set variables, session...
6
by: Nicolae Fieraru | last post by:
Hi All, I recently discovered that my session cookies on the web host disappear within 30 seconds. I created some very simple asp scripts (it took me a while until I discovered why my shopping...
11
by: Jennifer | last post by:
Is there a way to check for to see if the user has session cookies enabled? I know how to check to see if they have cookies in general enabled, but how do you test for just session cookies? ...
5
by: anony | last post by:
Hi, I have a site that uses forms authentication to secure the directory. The site behaves as expected when viewed externally... if I close the browser and attempt to access it again, I get...
5
by: CodeRazor | last post by:
In web app development you can use session, cookies, querystring to reference variables you set in a previously in the app. My question is how does windows let you access a variable value you set...
3
by: Jim Carlock | last post by:
I have a problem where session cookies get left inside the temporary folder. Is this a common problem or is there perhaps something I've over looked - there a way to make sure the session...
2
by: StanB | last post by:
I came across this weird problem: 1. Session state stops working after the app is deployed to another server because IE does not accept cookies. 2. It works if cookieless="true" in the...
3
by: dinesh1985singh | last post by:
Hello everyone, Could any one explain me the exact difference between session cookies ,session and cookies. I know about cookies and session well but I want to know the session cookies in deep...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.