View previous topic :: View next topic |
Author |
Message |
Dragonlord Guru
Joined: 22 Aug 2004 Posts: 446 Location: Switzerland
|
Posted: Sat Jun 30, 2012 6:18 pm Post subject: get vixie-cron to send HTML mails |
|
|
On my server I set vixie-cron to send mails to me each night. The cron jobs are written in a way they output important information to the console. This way I have an overview of what happens each night. The problem now is the information grew larger and larger over time. Especially with stuff like "rc-status" it's easy to overlook a problem like recently with ntpd crashing randomly. On the console you see this quickly as the status is red. In a black text mail though this error can go unnoticed easily.
So what I'm looking for now is a solution to get vixie-cron to send the colored output as a HTML mail. Can this be done directly with vixie-cron or do I need a HTML capture tool in between? _________________ DragonDreams: Leader and Head Programmer |
|
Back to top |
|
|
alex.blackbit Advocate
Joined: 26 Jul 2005 Posts: 2397
|
Posted: Sun Jul 01, 2012 11:27 am Post subject: |
|
|
a cron daemon just sends the output of the executed command via email. nothing more, nothing less.
It seems you would like to have ANSI color of console output in an email. Maybe this blog post[1] helps.
You somehow will have to make sure to set the right MIME type when sending HTML via email.
Also, I personally would not try to increase visibility of problems by adding color via HTML.
Try to extract relevant information with grep or something.
[1] http://pablomarin-garcia.blogspot.co.at/2011/04/converting-ansi-to-html-how-to-convert.html |
|
Back to top |
|
|
Dragonlord Guru
Joined: 22 Aug 2004 Posts: 446 Location: Switzerland
|
Posted: Sun Jul 01, 2012 5:50 pm Post subject: |
|
|
I'll give that post a read there. Concerning the grep-ing I had a similar idea but there is a problem. I've got various individual cron jobs in /etc/cron.daily which all do different things. Some backup files, some check web server stats and some others show system status so I can jump in if something unexpectedly goes wrong. The problem is all of those cron jobs get mangled together. Trying to grep through a mangled file where there is also foreign scripts (like webalizer) that output nilly willy stuff is a problem. With the color solution I could still keep all information for the case I want to check on the less important stuff once in a while while stumbling over red colored problems easily. Maybe you've got a different solution for this?
EDIT: The blog post you mentioned doesn't work. Stuff like rc-status seems to be clever and doesn't output color if it is piped. Looks like I need a bash replacement that writes to a colored HTML file instead. Something like a fake console. _________________ DragonDreams: Leader and Head Programmer |
|
Back to top |
|
|
alex.blackbit Advocate
Joined: 26 Jul 2005 Posts: 2397
|
Posted: Sun Jul 01, 2012 10:00 pm Post subject: |
|
|
interestingly rc-status does not have a --force-color option or similar.
obviously it uses isatty(3).
IMHO an option for force color should be available for every tool.
a patch should be quite easy to do.
it would just provide a code path around the isatty() call. |
|
Back to top |
|
|
|