LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-20-2011, 03:59 AM   #1
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 9

Rep: Reputation: 0
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 ?

please share your thoughts.

Thanks.
 
Old 02-20-2011, 04:11 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

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.

Hope this helps.
 
1 members found this post helpful.
Old 02-20-2011, 04:47 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
1 members found this post helpful.
Old 02-20-2011, 05:17 AM   #4
BoraxMan
Member
 
Registered: Apr 2010
Posts: 103

Rep: Reputation: 11
Quote:
Originally Posted by unSpawn View Post
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.
 
1 members found this post helpful.
Old 02-20-2011, 07:13 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by BoraxMan View Post
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 View Post
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 View Post
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


Quote:
Originally Posted by BoraxMan View Post
You can make the files immutable
Good one but following the FHS would be better.
 
1 members found this post helpful.
Old 02-21-2011, 04:03 AM   #6
sunrexstar
LQ Newbie
 
Registered: Feb 2011
Posts: 9

Original Poster
Rep: Reputation: 0
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.
 
Old 02-21-2011, 10:03 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Try /usr/local/bin
 
Old 02-21-2011, 10:48 AM   #8
mayursingru
Member
 
Registered: Nov 2010
Location: Pune
Distribution: CentOS
Posts: 51

Rep: Reputation: 5
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I just accidentally deleted my /tmp directory Daedra Slackware 3 05-30-2009 09:19 PM
getting files deleted on /tmp ines Linux - General 13 01-28-2005 03:35 AM
/tmp files being deleted new@linux Linux - Newbie 2 12-30-2004 01:51 PM
tmp directory being deleted jpokrzyk Linux - General 3 10-30-2004 06:42 PM
Anything in the SuSE 8.2 tmp directory that can't be deleted? alfredh Linux - Newbie 3 12-14-2003 03:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration