Home » Infrastructure » Unix » Deleting files from /var/tmp
Deleting files from /var/tmp [message #98048] Sat, 03 January 2004 00:04 Go to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
The user Applprod and appldev is creating .tmp files under the /var/tmp directory.I need a script which will clean up these files on a regular basis that is it must check and clean every 15 mts.My OS is sun solaris 8.

Rgds

Mike
Re: Deleting files from /var/tmp [message #98050 is a reply to message #98048] Sun, 04 January 2004 22:21 Go to previous messageGo to next message
Frank Naude
Messages: 4579
Registered: April 1998
Senior Member
Hi,

You can schedule a crontab script like this to delete files from your /var/tmp directory.

# Find files that were accessed more than 1 day ago...
find /var/tmp -type f -atime +1 | while read FILE
do
   echo Delete file ${FILE}...
   # rm -f $FILE
done


Best regards.

Frank
Re: Deleting files from /var/tmp [message #98060 is a reply to message #98050] Mon, 12 January 2004 22:23 Go to previous messageGo to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
Hi,

Thanks a lot for the mail.I need to delete files *.tmp from /var/tmp dir.I will have to schedule this script every 15 mts.How do I add it to the crontab?
Since I'm new to unix I would appreciate if you can provide me with complete steps?

Rgds

Mike
Re: Deleting files from /var/tmp [message #98061 is a reply to message #98060] Mon, 12 January 2004 22:44 Go to previous messageGo to next message
Werner
Messages: 11
Registered: November 1999
Junior Member
Hi Mike,

you can schedule the script by open crontab by typing
crontab -e, if you have the privileges to do that and add a line like:
0,15,30,45 * * * 1-6 <path>/del_temp.sh 2>/dev/null 1>&2

1-6 means that it run only from monday til saturday, use a "*" if you want to run every day.
The extension 2>/dev/null 1>&2 means that every output
of that script is put to device null otherwise the output will generate a email which of corse will fill up your mailbox.

Save your entry like vi with :wq

Regards,
Werner
Re: Deleting files from /var/tmp [message #98062 is a reply to message #98061] Tue, 13 January 2004 00:50 Go to previous messageGo to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
Thanks a lot.....
Re: Deleting files from /var/tmp [message #98113 is a reply to message #98060] Wed, 03 March 2004 07:10 Go to previous message
siva
Messages: 58
Registered: August 1999
Member
Hi,

In our server the size of the /var file system is 2GB. Daily tmp files are getting created in /var/tmp folder. Daily night we are removing the tmp files. but some times the size of the tmp files are huge and fills up the /var/tmp area so rapidly causing application services to stop. I want to know from how the tmp files are getting created. we are running forms server, report server, oc4j and apache server in our system. Increasing the /var/tmp size is out of question. It will be nice if we can redirect the files to some other folder. For that what I needs to do. Please advice.

Thanks in advance
siva
Previous Topic: oracle 8.1.7 on sco unixware 7.1.3
Next Topic: Java Runtime Environment not found
Goto Forum:
  


Current Time: Fri Mar 29 04:00:49 CDT 2024