LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-01-2012, 07:38 AM   #1
gabriel.560
LQ Newbie
 
Registered: Jan 2009
Posts: 17

Rep: Reputation: 0
prevent a subdirectory of /tmp from being deleted


Hi,

I'm running CentOS. I have a directory named /tmp/cim. I know that files under /tmp directory are automatically deleted after a certain period (if they are not modified). I want to keep /tmp/cim and all it's files no matter when they were last modified. How do i do that?

Thanks.
 
Old 01-01-2012, 08:20 AM   #2
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
You can try by setting immutable attribute on the directory you want

Quote:
chattr +i /tmp/cim
 
1 members found this post helpful.
Old 01-01-2012, 08:35 AM   #3
gabriel.560
LQ Newbie
 
Registered: Jan 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for the reply. I don't think it's what i'm looking because -i will also prevent everyone from changing the file, not only delete.
 
Old 01-01-2012, 09:17 AM   #4
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
If you want to stop all users/groups from managing files under the directory, you require to run chmod -R 700 /tmp/cim

Or If you want to prevent one user managing others file, you will need to setup sticky bit on /tmp/cim partition.
 
Old 01-01-2012, 02:30 PM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
I think there's a script run out of cron that cleans out /tmp periodically (on my box it's /etc/cron.daily/tmpwatch, which is run by cron once a day). You would probably have to modify it to not touch that particular directory.

This begs, the question, though: why on earth are you keeping data you want to preserve in /tmp?
 
Old 01-01-2012, 05:05 PM   #6
wpeckham
Senior Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 1,653

Rep: Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569
reinveinting the square wheel

The whole point of a tmp folder is that it is not persistent. If you want something to stay, you need to put it somewhere that is not under a tmp folder.

Last edited by wpeckham; 01-01-2012 at 05:05 PM. Reason: spellchecker in my fingers failed.
 
1 members found this post helpful.
Old 01-03-2012, 01:52 PM   #7
gabriel.560
LQ Newbie
 
Registered: Jan 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Thank you for the help. We used tmpwatch script and excluded the directory.

I know that it's a very bad choice to save files in /tmp but it wasn't my decision

Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Prevent subdirectory creation while allowing file creation bweddell Linux - Security 5 07-31-2011 09:54 PM
I carelessly deleted /tmp deco81 Linux - Newbie 2 07-01-2010 10:26 AM
how to prevent executing script in /tmp ? montyleesam Linux - Security 5 06-15-2008 09:15 AM
deleted contents of /tmp dave`2005 Slackware 2 06-22-2007 11:45 PM
getting files deleted on /tmp ines Linux - General 13 01-28-2005 04:35 AM


All times are GMT -5. The time now is 10:47 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration