View Full Version : crontab? emailing logs?
bobcrotch
06-09-2004, 03:14 PM
Kinda confused here, all i want to do is email a few logs to a certain external addy...i do this with crontab right?
Have crontab call sendmail, to send as an attachment. A sendmail command list may be found here. http://www.rt.com/man/sendmail.8.html
ameoba
06-09-2004, 04:52 PM
Cron just executes commands on some regular basis. As long as the commands aren't going to require user input or require a graphical output, you can do most anything you want with cron.
bobcrotch
06-09-2004, 05:02 PM
I guess i just need to go over the syntax for sendmail.
I understand what cron does, i guess i just don't understand what i need to do to get the results i want. So readup more on sendmail and just have SM send the attachment to the specified email addy via a cron job?
I guess i just need to go over the syntax for sendmail.
I understand what cron does, i guess i just don't understand what i need to do to get the results i want. So readup more on sendmail and just have SM send the attachment to the specified email addy via a cron job?
Yep. ;) That seems like the easiest method. Just remember that cron provides the timing functionality, of which to call sendmail's MTA functionality.
Soybomb
06-14-2004, 05:34 PM
I would look at some sort of log analysis program to catch logs that have been rolled due to size....
But the simplest way to do it in cron without worrying that rolled logs might be something like:
55 23 * * * cat /var/log/messages | mail -s "Nightly log report" root@localhost
tim_m
06-14-2004, 05:47 PM
MAILTO=email@site.com
0-59 * * * * cat /var/log/whatever
should also work. as i recall, cron only sends email if the command called writes to stdout, it intercepts it and emails it to the owner or provided address. the subject is like 'user crontab <command>'
Soybomb
06-14-2004, 05:53 PM
MAILTO=email@site.com
0-59 * * * * cat /var/log/whatever
should also work. as i recall, cron only sends email if the command called writes to stdout, it intercepts it and emails it to the owner or provided address. the subject is like 'user crontab <command>'
good point, i forgot completely about that...my codes bloated lol....although I do believe yours will run every minute with the 0-59
Gertrude
06-15-2004, 12:09 AM
For scripting email notifications I use SendEmail
http://caspian.dotconf.net/menu/Software/SendEmail/
This is a very simple example, but you could add something like this to cron.
cat /var/log/whatever | sendEmail -f you@domain.com -t destination@domain.com
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.