Mailing daily logs via cron?
Hi there
I would like to mail the contents of a directory, but not quite sure on the script to do this. What needs to happen: 1) Tar all the files in the directory 2) Mail the tar file 3) Clear the directory To script this as a daily cron, would this be correct? Code:
#!/bin/sh What am I missing here? Thanks! |
Yaaaaargh!
Don't delete the old logs so casually! don't throw information away, you'll almost always regret it! Look at man logrotate and rotate and archive your logs if you want them just in a mail message cat *.log | mailx -s subject user @ blah.com if you want an attachment uuencode logs.tar logs.tar | mailx -s subject user @ blah.com May work, depending on your MTA set-up at the other end, whether it decodes i think. (outlook usually works, yahoo doesn't). Otherwise look up your mailer how to attach a file. I think mutt -a will send an attachment. |
Advice: don't ever use rm * in a script.
use rm /var/logs/snort/* Consider this: Quote:
|
Thanks a lot :) This will definately work for me
|
All times are GMT -5. The time now is 07:50 AM. |