Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Freeing temp space

Hi,
On my solaris machine the /tmp folder appears cluttered. To free up the space, can I delete the files and folders or should I followup a procedure to check if the files are being still in use.

Thanks
0
wfaleiro
Asked:
wfaleiro
  • 2
1 Solution
 
TintinCommented:
A lot of systems use a cronjob to periodically clean out old files in /tmp and /var/tmp, eg:

find /tmp /var/tmp -type f -mtime +7 -exec rm -f {} \;
0
 
macker-Commented:
From a programming standpoint, /tmp should be considered unreliable, and the contents could disappear at any time.  Unfortunately, this is not always respected, and potentially in-use files may be there.  Noteable examples include screen sessions and MySQL's socket.

The find command referenced by Tintin is an excellent one for this purpose, as it will only delete files that were last modified no less than a week ago.  You may also wish to remove files based on name.  E.g. PHP has a habit of leaving session files laying around, and some user programs (especially KDE based) will often leave stale files that don't get deleted.  This may happen because of unexpected exits, sloppy programming, or any other number of reasons.

Also, if the server is rebooted, the files in /tmp are safe to delete (before programs are restarted).  If you want to check if any files are actively open and in-use by a program, check with lsof.  Note, though, that a program may still want to access a file but not have an active file handle open for it.
0
 
neteducationCommented:
macker: If the server is rebooted then /tmp is deleted, as /tmp is (by default) a ramdisk.

I basically agree with tintin's solution, even though, for a very small chance there could be files not being modified for a week and still being needed.

I personally "solved" this by rebooting the server when I apply the latest patchcluster (and by the reboot as said, the ramdisk is of course cleared). I know that this might not allways be possible, but if possible I think it's quite a good solution.
0
 
macker-Commented:
Ah, had not recalled that it's a ramdisk.  That certainly tidys things up.  In any regard, it sounds like Tintin's solution is the best by consensus.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now