LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 06: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, 07: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, 07: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, 08: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, 01:30 PM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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, 04:05 PM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,511

Rep: Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656
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 04:05 PM. Reason: spellchecker in my fingers failed.
 
1 members found this post helpful.
Old 01-03-2012, 12: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 08:54 PM
I carelessly deleted /tmp deco81 Linux - Newbie 2 07-01-2010 09:26 AM
how to prevent executing script in /tmp ? montyleesam Linux - Security 5 06-15-2008 08:15 AM
deleted contents of /tmp dave`2005 Slackware 2 06-22-2007 10:45 PM
getting files deleted on /tmp ines Linux - General 13 01-28-2005 03:35 AM

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

All times are GMT -5. The time now is 04:36 PM.

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