: Removing user files, but not mail folders?

: Removing user files, but not mail folders?

Post by Matthew Reis » Thu, 24 Nov 1994 16:44:43



I am a DNS/sendmail/general admin for several servers (4.1.3_U1).
I need to periodically cleanse the system of old user files.

Being a bit of a novice, I decided to use find as follows:
  find /home -atime +30 -size +20 -ok rm {} \;

I don't know how to avoid specific files (like shell startup files) using
find so I assumed such files would be smaller than 20 blocks and would
thus escape the find syntax above. (kludgy, I know).

Also, I'd really rather not incur user wrath by unceremoniously blowing
away mail folders (e.g. mbox). They use both /usr/ucb/mail and elm.  
Some are sly enough to rename a file 'mbox' to avoid an auto-wipe of
files of a "non-protected" name.

So:
 1. How to distinguish between files that are mail folders and other files?
 2. How to tell find: "Don't delete anybody's .login, .mailrc, etc.)?
 3. Am I barking up the wrong utility?
 4. How can I do this more elegantly?

T.I.A.
--
__________________________________________________________________________
Matthew R. Reiser

 
 
 

: Removing user files, but not mail folders?

Post by Albert Che » Fri, 25 Nov 1994 01:30:35



>I am a DNS/sendmail/general admin for several servers (4.1.3_U1).
>I need to periodically cleanse the system of old user files.

>Being a bit of a novice, I decided to use find as follows:
>  find /home -atime +30 -size +20 -ok rm {} \;

>I don't know how to avoid specific files (like shell startup files) using
>find so I assumed such files would be smaller than 20 blocks and would
>thus escape the find syntax above. (kludgy, I know).

>Also, I'd really rather not incur user wrath by unceremoniously blowing
>away mail folders (e.g. mbox). They use both /usr/ucb/mail and elm.  
>Some are sly enough to rename a file 'mbox' to avoid an auto-wipe of
>files of a "non-protected" name.

>So:
> 1. How to distinguish between files that are mail folders and other files?
> 2. How to tell find: "Don't delete anybody's .login, .mailrc, etc.)?
> 3. Am I barking up the wrong utility?
> 4. How can I do this more elegantly?

Your site has a policy to blow away user files in their own $HOME area?
That is a dangerous approach.  I wouldn't do such thing since I
may blow away my boss' important files.  If your site is tight in
disk space, there are two alternatives:

1) turn on the disk quota option and force users to clean up their
   own area.

2) divide up /home into two partitions, one small still named /home,
   the other bigger, called it /scratch.  Then setup the policy
   that files in /home are backed up regularly but files in /scratch
   is NOT backed up and whenever /scratch fills up, the system admin.
   can and will start removing files in /scratch until the free space
   amount is adequate again.

Oh, to answer your original question of identifying Mail files,
UNIX has just one plain file type (forget about /dev, named pipes, etc...)
You must look into the content of a file to find out what its purpose
MAYBE.  But then, you are updating the atime of the file, thus defeating
your original scheme.

 
 
 

: Removing user files, but not mail folders?

Post by Pierre Gaumo » Sat, 26 Nov 1994 01:55:18




>> [... stuff deleted ...]

>Your site has a policy to blow away user files in their own $HOME area?
>That is a dangerous approach.  I wouldn't do such thing since I
>may blow away my boss' important files.  If your site is tight in
>disk space, there are two alternatives:

I agree with this, why not instead send a message to the users saying that they
have large files (mention name, size, atime) that are not used and keep some
statistics?

--

Services Informatiques, Universite de Montreal.
C.P. 6128, Succursale centre-ville, Montreal,            
Quebec, Canada.   H3C 3J7                      

 
 
 

: Removing user files, but not mail folders?

Post by Pierre Gaumo » Sat, 26 Nov 1994 04:07:33





>>> [... stuff deleted ...]

>>Your site has a policy to blow away user files in their own $HOME area?
>>That is a dangerous approach.  I wouldn't do such thing since I
>>may blow away my boss' important files.  If your site is tight in
>>disk space, there are two alternatives:

>I agree with this, why not instead send a message to the users saying that they
>have large files (mention name, size, atime) that are not used and keep some
>statistics?

May I add that you may suggest to the users (or do it yourself?) to compress
their files, strip stable compiled executables, remove `core' and `a.out' files
or tar+compress some directories, merge small files (if many) in larger files
(to avoid disk space waste), etc... If you suspect that two fils may be
identical (check for hard links), you may ask the user to compae files and
remove one if both are not necesary.

Ask the users to remove files they can easily re-built or filess they copy from
the system (man pags, executables, scripts, etc...) or from other users.

Ask them to clean their mail folders or news files. If they don't read their
mail, put the message in /etc/motd or arrange /etc/cshrc to check it and send a
`visible' mesage.

I suggest you get GNU zip (gzip) because you usualy obtain better compressions
than with compress or pack.

Files on /tmp should not stay there very long, in this case, maybe you can
remove them (but advice the user) and establish a general politic about this.

--

Services Informatiques, Universite de Montreal.
C.P. 6128, Succursale centre-ville, Montreal,            
Quebec, Canada.   H3C 3J7                      

 
 
 

: Removing user files, but not mail folders?

Post by Stan Ryckm » Mon, 28 Nov 1994 02:26:34



[snipped]]

Quote:>Files on /tmp should not stay there very long, in this case, maybe you can
>remove them (but advice the user) and establish a general politic about this.

On all the UNIXes I know, /tmp is cleaned out whenever the system
gets rebooted.  Nothing should be put there unless being used
by an active process.

Stan.
--
HELP!  I'M BEING HELD PRISONER IN A .SIGNATURE FACTORY!

 
 
 

: Removing user files, but not mail folders?

Post by Pierre Gaumo » Mon, 28 Nov 1994 08:23:35





>[snipped]]
>>Files on /tmp should not stay there very long, in this case, maybe you can
>>remove them (but advice the user) and establish a general politic about this.

>On all the UNIXes I know, /tmp is cleaned out whenever the system
>gets rebooted.  Nothing should be put there unless being used
>by an active process.

I'm not sure of it. Recently, someone has posted an article in which he said he
found a large file on /tmp after the machine crashes (and was necessalily
rebooted). Maybe, it's an installation option that is activated by almost
everyone.

>Stan.
>--
>HELP!  I'M BEING HELD PRISONER IN A .SIGNATURE FACTORY!


--

Services Informatiques, Universite de Montreal.
C.P. 6128, Succursale centre-ville, Montreal,            
Quebec, Canada.   H3C 3J7                      
 
 
 

: Removing user files, but not mail folders?

Post by Stan Ryckm » Mon, 28 Nov 1994 08:54:37







>>[snipped]]
>>>Files on /tmp should not stay there very long, in this case, maybe you can
>>>remove them (but advice the user) and establish a general politic about this.

>>On all the UNIXes I know, /tmp is cleaned out whenever the system
>>gets rebooted.  Nothing should be put there unless being used
>>by an active process.

>I'm not sure of it. Recently, someone has posted an article in which he said he
>found a large file on /tmp after the machine crashes (and was necessalily
>rebooted). Maybe, it's an installation option that is activated by almost
>everyone.

I think what usually happens is that /etc/rc (or equivalent script,
depending on UNIX flavor) is run on startup and does a "rm -rf /tmp/*"
which does the deed.  (Ours do /usr/tmp where applicable, as well.)
UNIX itself does not "care" (if I may anthropomorphize) about /tmp.
That user's site may have done something strange with the startup
script(s).

A few years back, I found a case where directories were being
created in /tmp, but the script only did "rm /tmp/*", so any stuff
in subdirectories was not cleared.  Another case that could fail is
that some process goes berserk, creating zillions of files in
/tmp, and "rm -rf /tmp/*" results in the error "arguments too long"
or similar.

I suppose a "correct" implementation would do either
    (a) find, piped to xargs rm; or
    (b) rm -rf /tmp; mkdir /tmp; chmod /tmp 777
(although "b" has some problems where /tmp should have attributes
preventing X from deleting Y's files).

And, of course, substitute "/bin/rm" for "rm" everywhere above
just to be safe!

Cheers,
Stan.
--
HELP!  I'M BEING HELD PRISONER IN A .SIGNATURE FACTORY!

 
 
 

1. : Removing user files, but not mail folders?

I am a DNS/sendmail/general admin for several servers (4.1.3_U1).
I need to periodically cleanse the system of old user files.

Being a bit of a novice, I decided to use find as follows:
  find /home -atime +30 -size +20 -ok rm {} \;

I don't know how to avoid specific files (like shell startup files) using
find so I assumed such files would be smaller than 20 blocks and would
thus escape the find syntax above. (kludgy, I know).

Also, I'd really rather not incur user wrath by unceremoniously blowing
away mail folders (e.g. mbox). They use both /usr/ucb/mail and elm.  
Some are sly enough to rename a file 'mbox' to avoid an auto-wipe of
files of a "non-protected" name.

So:
 1. How to distinguish between files that are mail folders and other files?
 2. How to tell find: "Don't delete anybody's .login, .mailrc, etc.)?
 3. Am I barking up the wrong utility?
 4. How can I do this more elegantly?

T.I.A.
--
__________________________________________________________________________
Matthew R. Reiser

2. Setup errors on floppy change..help...

3. removing duplicate mails in a mail folder

4. comp.mail.sendmail

5. Removing duplicate mail messages from a folder

6. Getting first field in files??

7. mail folder is in /var/mail or /var/spool/mail

8. SNMP via SIA

9. Mails do not get removed from Mail Queue

10. Script to remove files and folders

11. What setting do I need for the /var/spool/mail/USER folders?

12. chmod of all the files and sub folders under one folder

13. rm folders, sub-folders and files older than one hour