LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Files in /tmp directory (https://www.linuxquestions.org/questions/solaris-opensolaris-20/files-in-tmp-directory-692907/)

Yeung 12-25-2008 08:58 AM

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

geek745 12-25-2008 04:34 PM

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.

popowich 12-30-2008 10:43 AM

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

Yeung 12-31-2008 03:00 AM

Quote:

Originally Posted by popowich (Post 3391676)
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

My clients run scientific simulations in the machine. These programs generate huge transient files in sub-directories in /tmp. If /tmp gets too small, the simulation programs might hang. There are many clients, each with very long simulation jobs often in multiple days. Rebooting the machine frequently to clean /tmp is not practical, so I want to clean the /tmp daily with a cron job.

Yeung

crisostomo_enrico 01-01-2009 07:10 AM

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.