crontab? emailing logs?

bobcrotch

[H]ard|Gawd
Joined
Mar 12, 2003
Messages
1,484
Kinda confused here, all i want to do is email a few logs to a certain external addy...i do this with crontab right?
 
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.
 
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?
 
bobcrotch said:
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.
 
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
 
Code:
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>'
 
tim said:
Code:
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
 
Back
Top