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.
 
ashsysadAsked:
Who is Participating?
 
ajay_mhasalConnect With a Mentor Commented:
HI,

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 http://linux.die.net/man/8/tmpwatch

0
 
TintinCommented:
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?
0
 
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.
0
 
ashsysadAuthor Commented:
Hi Ajay, Thanks for introducing me to 'tmpwatch' command.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.