1753801 Members
8144 Online
108805 Solutions
New Discussion юеВ

Temportay file deletion

 
Pintu Bhagat
Occasional Advisor

Temportay file deletion

what type of file can we delete if the /tmp get breached.
6 REPLIES 6
MarkSyder
Honored Contributor

Re: Temportay file deletion

The nature of the tmp directory is (or should be)that the files are temporary. In this instance, I always start by deleting anything over a week old:

cd /tmp
find . -mtime +7 -exec rm {}\;

If there's still a problem I look at the largest files:

ll|sort -k5,5nr|pg

Unless the file at the top is very new I would be inclined to get rid of it.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Ralph Grothe
Honored Contributor

Re: Temportay file deletion

Does your question translate to,
is anything necessary to be recovered that used to be in a lost /tmp filesystem?
Maybe this will answer it a little.
On Solaris boxes the /tmp filesystem is merely part of swap,
which means that you get an autoclaen of its content whenever you reboot.
Madness, thy name is system administration
Luk Vandenbussche
Honored Contributor

Re: Temportay file deletion

It is /tmp so if the application are OK, you could remove everything.

You can also clear the tmp dir automaticaly at every reboot by changing the paramater

CLEAR_TMP in /etc/rc.config.d/clean_tmps
Steven E. Protter
Exalted Contributor

Re: Temportay file deletion

Shalom,

What find can be deleted depends on what is there and who owns it.

The general purpose of the directory is temp files and the directory is normally read-write-execute for all users.

What sometimes happens is congestion and applications not cleaning up after themselves.

Normally I handle it with a cron job that gets rid of files not accessed in the last 7 days.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
AwadheshPandey
Honored Contributor

Re: Temportay file deletion

Managing /tmp and /var/tmp
-----------------------------------------

/tmp is one of those directories where everyone has access but few seem to
treat it with respect. /tmp is defined as a temporary storage area and is
not to be considered permanent. Processes like email or the vi editor use
the /tmp directory for files, but normal operations will cleanup afterwards
and not leave files in the /tmp directory. Some HP programs will leave
their logfile in /tmp, but this is considered correct practice in
that the logfile should be reviewed for errors, and then removed or archived.

There is a caveat that customers who are running Omniback should be
aware of. Omniback require that a file called CRS.pid exist in the /tmp
directory. Otherwise Omniback will not work.

One way to enforce cleanup of the /tmp directory is to use a command such as:

find /tmp -type f -atime +14 -exec rm {} \;

which will remove any files in /tmp (or files in directories below /tmp)
that have not been accessed in more than 14 days. The other temporary
storage area, /var/tmp, is less often abused by users since they overlook
it's existence. Again, some processes will create temporary files in
/var/tmp and should (if they terminate correctly) remove their files
and editors like vi use /var/preserve. This command
will clear up /var/tmp of files not accessed in more than 7 days:

find /var/tmp -atime +7 -exec rm {} \;

System administrators need to decide if /tmp should allow regularly accessed
files to stay in /tmp. A user might bypass the above tests by using the
touch command on the files. In this caase, change the -atime option to
-mtime which means that the file must be modified.

Once in a while, you may need to check for old directories which are not
removed by the above command. The contents will be cleared but after a
while, /tmp may get cluttered with empty directories.

Here's a possibility for files in directories. This combination purges
files that are older than 7 days, followed by a removal of the directory
if it hasn't been updated for 7 days. However, a simple rmdir is used
so the command will fail if the directory isn't empty. Thus, until all
files have been removed, the directory will stay.

find /tmp -type f -atime +7 -print -exec rm -f {} \;
find /tmp -type d -atime +7 -print -exec rmdir {} \;
find /var/tmp -type f -atime +7 -print -exec rm -f {} \;
find /var/tmp -type d -atime +7 -print -exec rmdir {} \;

Another common practice is to cleanup /var/tmp after every full backup.
It's kind of fun to do the impossible
James R. Ferguson
Acclaimed Contributor

Re: Temportay file deletion

Hi:

Everything depends on your management scheme. As noted, you can elect to automatically remove everything in the '/tmp' directory during reboot and startup, by setting CLEAR_TMP=1 in '/etc/rc.config.d/clean_tmps'.

Strictly speaking, according to standards [see the 'hier(5)' manpages], the '/tmp' directory is for *system* temporary files whereas '/var/tmp' is intended for *application* files.

My preference is not to automatically clean the '/tmp' directory, but periodically purge (manually and programatically) what I don't want. I don't want '/tmp' automatically cleaned upon reboot in order to preserve patch depots and/or individual patches that I may have staged there for installation following a reboot "health-check" prior to installation.

Regards!

...JRF...