Hi there i need a cron script that cleans every day crap into /tmp I have there a lot of temp files but i dunno which ones can be safely wiped, and it is very time comsuming job, too. Any script written by someone of you will be very apreciated :) tia Maurizio
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/31/2010 09:52 PM, Maurizio Marini wrote:
Hi there i need a cron script that cleans every day crap into /tmp I have there a lot of temp files but i dunno which ones can be safely wiped, and it is very time comsuming job, too. Any script written by someone of you will be very apreciated :) tia Maurizio
There already is a cron that will delete file out of /tmp that are 10 days old.
I take it by your request that this is insufficient for you (sound like /tmp is too small for your needs :-)
Be that as it may, take a look at /etc/cron.daily/tmpwatch It will give you an idea of what shouldn't be deleted...
All the best,
- -Greg
- -- +---------------------------------------------------------------------+
Please also check the log file at "/dev/null" for additional information. (from /var/log/Xorg.setup.log)
| Greg Hosler ghosler@redhat.com | +---------------------------------------------------------------------+
Gregory Hosler ghosler@redhat.com writes:
On 03/31/2010 09:52 PM, Maurizio Marini wrote:
Hi there i need a cron script that cleans every day crap into /tmp I have there a lot of temp files but i dunno which ones can be safely wiped, and it is very time comsuming job, too. Any script written by someone of you will be very apreciated :) tia Maurizio
There already is a cron that will delete file out of /tmp that are 10 days old.
In addition, at shutdown time everything in /tmp is fair game for deletion. As one of the last things done on all my machines I clean out /tmp. In my case the reason isn't space, but clutter. With the default /tmp cleaning, things build up to such a level that downloaded files that I only want to look at once are hard to find (such as pdf files etc).
Put this in /sbin/halt.local mode 755.
#!/bin/sh ############################################################################### ## ## ## File: halt.local ## ## Author: Wolfgang S. Rupprecht wolfgang@wsrcc.com ## ## Created: Thu Jun 7 23:47:14 PDT 2007 ## ## Contents: wsrcc site-specific halt stuff ## ## ## ## Copyright (c) 2007 Wolfgang S. Rupprecht. ## ## All rights reserved. ## ## ## ## $Id$ ## ############################################################################### # wsrcc halt script
echo "WSRCC: Clearing /tmp"
cd / /bin/rm -rf /tmp/* /tmp/.??* sync; sync; sync;
# # end #
i need a cron script that cleans every day crap into /tmp I have there a lot of temp files but i dunno which ones can be safely wiped, and it is very time comsuming job, too.
There already is a cron that will delete file out of /tmp that are 10 days old.
In addition, at shutdown time everything in /tmp is fair game for deletion. As one of the last things done on all my machines I clean out /tmp. In my case the reason isn't space, but clutter. With the default /tmp cleaning, things build up to such a level that downloaded files that I only want to look at once are hard to find (such as pdf files etc). Put this in /sbin/halt.local mode 755.
#!/bin/sh ############################################################################### ## ## ## File: halt.local ## ## Author: Wolfgang S. Rupprecht wolfgang@wsrcc.com ## ## Created: Thu Jun 7 23:47:14 PDT 2007 ## ## Contents: wsrcc site-specific halt stuff ## ## ## ## Copyright (c) 2007 Wolfgang S. Rupprecht. ## ## All rights reserved. ## ## ## ## $Id$ ## ############################################################################### # wsrcc halt script echo "WSRCC: Clearing /tmp" cd / /bin/rm -rf /tmp/* /tmp/.??* sync; sync; sync;
Or turn /tmp into a tmpfs mount.
On Wed, 2010-03-31 at 16:28 -0400, Tom H wrote:
Or turn /tmp into a tmpfs mount.
That can come back to bite you when you go to burn a CD or DVD, the burner uses /tmp to make temp files, and you run out real RAM.
Wolfgang S. Rupprecht wrote:
Gregory Hosler ghosler@redhat.com writes:
On 03/31/2010 09:52 PM, Maurizio Marini wrote:
Hi there i need a cron script that cleans every day crap into /tmp I have there a lot of temp files but i dunno which ones can be safely wiped, and it is very time comsuming job, too. Any script written by someone of you will be very apreciated :) tia Maurizio
There already is a cron that will delete file out of /tmp that are 10 days old.
In addition, at shutdown time everything in /tmp is fair game for deletion. As one of the last things done on all my machines I clean out /tmp. In my case the reason isn't space, but clutter. With the default /tmp cleaning, things build up to such a level that downloaded files that I only want to look at once are hard to find (such as pdf files etc).
Put this in /sbin/halt.local mode 755.
I don't think the OP wanted overkill once in a while, scalpel rather than hammer. I think cruft is the target, and without a reboot.
Am 31.03.2010 15:52, schrieb Maurizio Marini:
Hi!
i need a cron script that cleans every day crap into /tmp I have there a lot of temp files but i dunno which ones can be safely wiped, and it is very time comsuming job, too. Any script written by someone of you will be very apreciated :)
There is no need to reinvent the wheel. Fedora comes with tmpwatch, which does exactly what you want - scans /tmp (and possibly other directories) and deletes unused files.
I do not have access to my computer right now, but "man tmpwatch" should help you.
If I'm not mistaken, tmpwatch is called regularly by cron from /etc/cron.daily (?).
On Wed, 2010-03-31 at 15:58 +0200, Adalbert Prokop wrote:
There is no need to reinvent the wheel. Fedora comes with tmpwatch, which does exactly what you want - scans /tmp (and possibly other directories) and deletes unused files.
Not quite... It will delete not recently looked at files, whether you actually used them or not. It's an important distinction, here's why:
If you do something like list the contents of /tmp in Nautilus or Konqueror, or use any indexing thingy that looks through /tmp, you've just /read/ those files again, and reset the timeout. Do that often enough, and tmpwatch will never clear out those files.
I've been careful to avoid doing any of that, and still find /very/ old files in the /tmp directory. I still haven't found out what's doing it.
On 31 March 2010 07:51, Tim ignored_mailbox@yahoo.com.au wrote:
On Wed, 2010-03-31 at 15:58 +0200, Adalbert Prokop wrote:
There is no need to reinvent the wheel. Fedora comes with tmpwatch, which does exactly what you want - scans /tmp (and possibly other directories) and deletes unused files.
Not quite... It will delete not recently looked at files, whether you actually used them or not. It's an important distinction, here's why:
If you do something like list the contents of /tmp in Nautilus or Konqueror, or use any indexing thingy that looks through /tmp, you've just /read/ those files again, and reset the timeout. Do that often enough, and tmpwatch will never clear out those files.
I've been careful to avoid doing any of that, and still find /very/ old files in the /tmp directory. I still haven't found out what's doing it.
I think you can play with the options [ -u | -m | -c ] to get what you want.
-- [tim@localhost ~]$ uname -r 2.6.27.25-78.2.56.fc9.i686
Am 31.03.2010 16:51, schrieb Tim:
Hi!
On Wed, 2010-03-31 at 15:58 +0200, Adalbert Prokop wrote:
There is no need to reinvent the wheel. Fedora comes with tmpwatch, which does exactly what you want - scans /tmp (and possibly other directories) and deletes unused files.
Not quite... It will delete not recently looked at files, whether you actually used them or not. It's an important distinction, here's why:
I did not want to exaggerate the distinction between creation/modification/access time - simplifications are helpful in explanations. ;)
But yes, there is clearly a difference. Just listing the contents of a directory will not change the file access time, but reading the files surely will.
I've been careful to avoid doing any of that, and still find /very/ old files in the /tmp directory. I still haven't found out what's doing it.
I do not have those problems because my /tmp partition is encrypted and recreated on every reboot with a random key. Another idea which might help: create a script /sbin/halt.local which deletes all contents of /tmp. Or calls tmpwatch which can pay attention to the modification time. This way /tmp can be purged at least on every reboot - still, it does not help on machines which are running for a long time.
Tim:
Not quite... It will delete not recently looked at files, whether you actually used them or not. It's an important distinction, here's why:
Adalbert Prokop:
I did not want to exaggerate the distinction between creation/modification/access time - simplifications are helpful in explanations. ;)
I prefer not to oversimplify things to the point that they're misleading or incorrect. If you think that files aren't being "used" when that isn't really the deletion criteria, you're going to get confused trying to work out why they're not being deleted.
But yes, there is clearly a difference. Just listing the contents of a directory will not change the file access time, but reading the files surely will.
That depends on what you use to list them. In the command line, you're just going to read the directory. In a graphical manager, it's probably going to look into the files, to determine what type they are, while listing them, not just when you try to open one of them.
As far as deleting /tmp files on shutdown or startup, as a solution, I suggest doing so on shutdown. That way they only get deleted on good shutdowns. On a crash, temp files are still there when you reboot, so you can check things out as part of your diagnosis.