Re: Maintenance Scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2003-07-16 at 14:17, John Haxby wrote:
> Thom Paine wrote:
> 
> >                                                                 
> ># Find and delete temp files
> >cd /home
> >find -name *.tmp -exec rm -f {} \;
> >find -name *.TMP -exec rm -f {} \;
> >find -name *.bak -exec rm -f {} \;
> >                             
> >
> This is going to annoy people.   If I create a file called something.bak 
> and then go home it'll get deleted during the night.    Actually, 
> removing what you think might be temporary files is a Bad Thing(TM) 
> anyway, it's better to let users do it themselves.    If you're still 
> sure you want to go ahead, do something like this:
> 
>     find -type f -atime +3 \( -iname '*.tmp' -o -iname '*.bak' -o -iname 
> '*~' \) -print0 | xargs -0 rm -f
> 
> (you might have to join lines together).   This deletes likely looking 
> files, and only files, that haven't been read in the last three days 
> (mtime is the wrong argument, think about it).  The "-print0" and "-0" 
> make sure that filenames with spaces, newlines, whatever don't cause 
> problems.
> 
Good point, maybe I will leave .bak in.
Basically the servers I run are just file and email and print servers,
so I think that getting rid of at least the .tmp files is okay. Most of
the users aren't that knowledgeable to make a .bak of a file before
working with it. They could do with a couple of good workshops. :)

> >                                                   
> ># Report each users home folder size
> >                                                                                
> >cd /home
> >du -c -h --max-depth=1 > /root/homesize.txt
> >
> I would think that
> 
>     du -s | sort -nr > /root/homesize
> 
> (I hate those windows extensions) would be better because it'll put the 
> biggest users at the home and only report the home directories.   "-h" 
> is nice for readability, but not so good for postprocessing.   Anyway, a 
> huge number next to your name at the top of the list is likely to be an 
> embarrasment!  (Not that it's ever happened to me you understand :-))   
> Of course, there's no reason to send the output anywhere, if you don't 
> (and it's in a cron job) then the whole lot will be mailed to you -- so 
> you could do this:
> 
>     echo
>     echo DISK USAGE
>     echo ==========
>     du -s /home/* | sort -nr
> 

Yes, the lot will just be mailed back to me and then I just have an idea
of where the space is going. What brought this on was a server I manage
suddenly 'lost' 25G worth of space. So that is where this exercise came
in and I finally 'found it' in the form of .mp3. So I quietly talked to
the user and they removed them. Turns out they were wiping their laptop
off and reloading it and wanted to save their music. 
I'm not interested in quotas. All of the networks I run are small
business with less than 25 users. It's a nice working relationship and
I've gotten to know everyone personally. They can have 'free reign' as
long as it's not abused.


> If you're trying to control disk space, however, you might want to look 
> at imposing quotas.   Having a quota is a really good incentive to clear 
> up your own temporary files and whatnot.   There's also the advantage 
> that since the filesystem maintains the usage structures getting a 
> summary is very fast.   Bear in mind though that you really want to 
> over-subscribe the amount of disk space (hotels and airlines know all 
> about this and it really does make sense, I think I used to 
> over-subscribe by 10-25% when I enforced quotas on   the 200Mb /home we 
> had then).
> 
> ># Disk Free List
> >df -h > /root/diskfree.txt
> >  
> >
> I find it amazingly difficult to run my eye down a list of different 
> units and compare them.
> 
> 

Lots of great help so far.
Thanks everyone. I'll work with this for a bit and see how I make out.

-=/>Thom



-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux