Managing /tmp filesystem in Redhat Linux

In my company, developers and testers are habitual to copy their files under /tmp rather than their home folders. At times, I used to see files of even in GBs. Inorder to bring this under control, I'm considering to write a script that can be run on a crontab for deleting all the unwanted user files in /tmp filesystem. Before developing a script, I want to get clarified with few questions about /tmp filesystem.

1. What files can be deleted from /tmp filesystem ?
2. How can I ensure that only user files are getting deleted (not files used OS) ?
3. What is the time limit (in days) I can set for a file to reside in /tmp filesystem ?
4. Finaly a straight forward solution: Can I restrict the users from coyping into /tmp filesystem and make only OS writes on it?

Please let me know ur suggestions. Thanks.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1.  root user can delete any files, otherwise files can be deleted based on their ownership and permissions.

2.  Generally, any tmp files used by OS processes will be owned by root and can only be deleted by root.

3.  There's no default time limit.  Usually the files get deleted after reboot.

4.  If you don't want non-root users copying files to /tmp, then change permissions from 1777 to 755 (although this could possibly cause problems with valid non-root users trying to write to /tmp).  What reason do you want to restrict /tmp?
ashsysadAuthor Commented:
Hi Tintin, as I mentioned in my question, the users in our company are dumping their files in /tmp and later failing to delete those. This sometimes cause performance issue with the server. Hence I want to delete all the files apart from the ones used by OS processes.

To resole your issue you can use tmpwatch command to delete the files based on their access, creation, or modification time.

Pl. refer following eg. to delete files from /tmp dir which are not accessed within last 24 hrs.

# tmpwatch -u --fuser 24 /tmp

For more details pl. visit


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ashsysadAuthor Commented:
Hi Ajay, Thanks for introducing me to 'tmpwatch' command.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.