-   Linux - Newbie (
-   -   prevent a subdirectory of /tmp from being deleted (

gabriel.560 01-01-2012 07:38 AM

prevent a subdirectory of /tmp from being deleted

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?


blue_print 01-01-2012 08:20 AM

You can try by setting immutable attribute on the directory you want


chattr +i /tmp/cim

gabriel.560 01-01-2012 08:35 AM

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.

blue_print 01-01-2012 09:17 AM

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.

btmiller 01-01-2012 02:30 PM

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?

wpeckham 01-01-2012 05:05 PM

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.

gabriel.560 01-03-2012 01:52 PM

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.

All times are GMT -5. The time now is 12:29 AM.