Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.