when or how often the files in /tmp directory get deleted on RHL
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
when or how often the files in /tmp directory get deleted on RHL
HI,
I am using a Red Hat Linux release 9 (Shrike).
I have a shell program that makes use of a particular file (that i myself have put) in the /tmp directory
Now, so far everything is good with the program execution.
My only fear is about the files in the /tmp getting deleted.
is it true that the files in /tmp get deleted?
if yes, how often and when.
Also, in order to test the same i rebooted the machine and saw that no files in the /tmp were deleted.
so, am i good to go with my file in /tmp directory ?
Although I'm not 100% sure if RedHat 9 does delete the files in /tmp, it is not a good idea to use /tmp to store files for later use.
The FHS recommends /tmp to be deleted whenever the system is booted. It is a recommendation, not a requirement so RH9 might or might not delete the content of /tmp.
I would suggest using a different location to store your files, if you ever switch distro's (or have to work on a different one) you won't get any nasty surprises.
RHL9 (which BTW is deprecated, unsupported and vulnerable to a host of exploits and should not ever be used connected to any network) will delete files in /tmp if tmpwatch is installed ('rpm -q tmpwatch' or 'which tmpwatch') and its /etc/cron.daily/tmpwatch cronjob runs. I agree /tmp is not the place to store files, not only because of the FSSTND / FHS but also because /tmp is shared by all users, so if you use the wrong umask or explicitly set write rights for others you're setting yourself up for a nasty surprise.
RHL9 (which BTW is deprecated, unsupported and vulnerable to a host of exploits and should not ever be used connected to any network) will delete files in /tmp if tmpwatch is installed ('rpm -q tmpwatch' or 'which tmpwatch') and its /etc/cron.daily/tmpwatch cronjob runs. I agree /tmp is not the place to store files, not only because of the FSSTND / FHS but also because /tmp is shared by all users, so if you use the wrong umask or explicitly set write rights for others you're setting yourself up for a nasty surprise.
I believe tmpwatch takes into account when the file was accessed and deletes those which haven't been accessed in a while. I don't believe it runs by default and being a long time RH 7.3 user (not anymore), I've never known it, or any of the later red hat releases I've used to delete files in /tmp
You can make the files immutable, which means that even God himself cannot delete them.
use
chattr +i filename
But you have to be root to set/unset. It also will block any changes to the file. I don't know if you need to modify it, or just read it. No process can delete the file now, not even those run by root.
I believe tmpwatch takes into account when the file was accessed and deletes those which haven't been accessed in a while.
True. So after ten days (IIRC the default) of a file not having it's atime (default) updated one wonders where it is...
Quote:
Originally Posted by BoraxMan
I don't believe it runs by default
Can't remember if it was a default base installation in Red Hat Linux but once installed it installs its cronjob.
Quote:
Originally Posted by BoraxMan
and being a long time RH 7.3 user (not anymore), I've never known it, or any of the later red hat releases I've used to delete files in /tmp
Only goes to show that because you've never known it this doesn't automagically mean it doesn't exist. I'm pretty sure I encountered it in Red Hat Linux 5
thank you folks.
it helps...
so which location on my linux system do you recommend to have this file placed?
something that is safe to place the file in.
Last edited by sunrexstar; 02-21-2011 at 04:21 AM.
Hi Everyone,
The files in /tmp are deleted after a specified period of time. I think this definitely depends upon factors mentioned by BoraxMan but some files on my RedHat where deleted after 30 days.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.