Emptying logfiles

Emptying logfiles

Post by Bo Forslun » Sat, 09 Aug 1997 04:00:00



Hello!

Can somebody say what I should tell cron so it emties the log files and
mail them to root.

When I had redhat 3.0.3 and 4.0 cron mailed the logs.  Now I have had
4.2 for a while and cron never post anything to root.

Bo

 
 
 

Emptying logfiles

Post by Johann Snyma » Sat, 09 Aug 1997 04:00:00



Quote:> Can somebody say what I should tell cron so it emties the log files and
> mail them to root.

> When I had redhat 3.0.3 and 4.0 cron mailed the logs.  Now I have had
> 4.2 for a while and cron never post anything to root.

#___________START___________
#!/bin/sh

#Remove Messages file every day and mail it to root
find /var/log/messages -size +1k -exec mail -s "{}" root < /var/log/messages \;
-exec cp /dev/null {} \;

#Remove cron Logfile every day and mail it to root
find /var/log/cron -size +1k -exec mail -s "{}" root < /var/log/cron \; -exec cp
/dev/null {} \;
#_________EOF________

Have cron run this script whenever you want.

---

Outlaw laws and soon all laws will be outlaws.
Linux DragonWing 2.0.27

 
 
 

1. Replacing >=1 white-space or empty lines with 1 empty line

Hello,

Could some kind soul please post a sed or awk script (or some other
universal UNIX tool) which scans its stdin for any adjacent set of
lines (\n terminated, 1 or more lines in the set) each of which is
either empty or all white-space (\t or ' '), and replaces each such
set in stdout with a single empty line (leaving all other throughput
unaltered).

So when (e.g.) you catted the file:

one
<empty>
two
<space>
<tab><space>
<empty>
three
<tab>
four

into it, the output is:

one
<empty>
two
<empty>
three
<empty>
four

Thanks if you can help!

2. Ultra and ATM

3. truncating a growing logfile

4. troff for HP Laserjet?

5. better than "$cmd 2>&1 | cat - > $logfile" ?

6. Ever had your file system currupt? (help? somebody?)

7. Can't get the same logfile with crontab

8. Missing libraries

9. logfiles to database?

10. Grepping lines from logfile reading date

11. redirect stderr to both screen and logfile at same time?

12. detecting automated accesses in logfiles

13. apache logfiles question