Files in /tmp directory
Hi,
I want to write a cron script to clean up files older than 10 days in the /tmp directory of a Solaris 10 machine. But I always find strange files in this directory like ".ICE-unix", ".X11-pipe","rootswup.trc"....etc. I am wondering if there are system files in this directory that shouldn't be removed. I am worrying the system might be in trouble if any of these files missed. Is there a check list telling which files should be kept in this directory? Thank you. Rgds, Yeung |
tmp means temporary - that doesn't necessarily mean expired. sometimes files, especially those that are hidden, are currently in use by a program. try running stat on them to see if they've been accessed since you last logged in. If they're left over from a previous session, I would say it's safe to delete them.
|
Hello,
I'm curious why you are looking to do this? Is there a problem that you are trying to solve? Solaris will clear this space on reboots, not that you should need to do reboots often except for installing patches and such. Do you have a program using /tmp that might be better off using another path for it's temp files? -Raymond |
Quote:
Yeung |
It sounds like these simulations are not properly cleaning up the temporary space they use during their jobs.
The first thing I'd do, if it's possible, would be having these processes using a known set of subdirectories below /tmp instead of trying to understand when and which system process could use a file you could find under /tmp: that approach doesn't seem so solid to me. Once you have this directory enumeration you could write a script which uses the fuser command to determine if a process is using a file or a directory some way and if not, delete it. See fuser man page for more details. You could also use other parameters to filter out the files you're looking for, such as the last access time. Approaches may also depend on how quickly you're running out of space on /tmp. By the way, I'm not sure I would run such a task once a day. If the script you write is performing well you could plan its execution more times per day to go cleaning up stale files more often. |
All times are GMT -5. The time now is 09:08 PM. |