LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-06-2004, 06:31 PM   #1
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Rep: Reputation: 30
Removing files wihtout removing containing Direcotry


I am hoping that there is a simple answer to my question.

I am using Fedora Core 2 as my primary OS at home. It has been running prefect for at least two weeks now, but I have noticed that my "/tmp" directory has gotten rather large. I know I can simply do the following commands to clear it all out:
cd /tmp
rm *

And the directory will be cleared without question (I have unaliased RM in my version).

So, on to my question:

I wish to write a cron entry to do this for me once a week, I know the format of the cron table, but the command to delete the CONTENTS of the "/tmp" while RETAINING the "/tmp" directory elude me.

Any help would be great, and thanks.

P.S - Any RedHat fans that do not own the Genuine "RedHat" Fedora should seriously consider getting one!
 
Old 10-06-2004, 09:22 PM   #2
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Code:
rm -fr /tmp/*
Should do the trick. You need the -fr switch in order to delete any sub-directories of /tmp, and do it without trying to prompt for each file.

I suggest that you try this manually before you actually set up the cron job. Then you could write a script that does this, and place it /etc/cron.weekly.

I hope this helps
--Ian
 
Old 10-07-2004, 08:16 AM   #3
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Original Poster
Rep: Reputation: 30
Oh man! My LUG would be ashamed of me! I can't believe the difference a "/" makes!

Thanks alot!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
removing last created files Prasun1 Linux - General 7 09-25-2005 07:31 PM
removing files kjs Linux - Software 1 02-17-2005 02:18 PM
Removing temporary files joe-uncle Linux - Newbie 3 10-29-2004 11:51 AM
Removing all files with the same date. Bookmarc Linux - General 1 08-12-2002 03:35 PM
Removing files ascii2k Linux - General 2 11-26-2001 11:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration