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

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

Freeing temp space

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.

  • 2
1 Solution
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 {} \;
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.
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.
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.

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