A Status Board for your Crontab

Over the past week I threw together a “status board” that I’ve hooked into my crontab.  Since I don’t log into my linux server on a daily basis to check logs/mail output and i don’t always give my full attention to automated messages that come to my main mailbox, a status board is a good compromise.  If everything is in order I can review in a quick glance, if there is an error i know where i need to look into later.  Simple highlighting of errored jobs stands out in a different color.

For me this is also a learning exercise in Go (http://golang.org/) so the code could be vastly improved.  Essentially, what we are doing is taking command line options to either update a status or output the “database” to html.  The database is just a simple json file living in ~/.status. I left what is meant by “object” and “status” pretty vague to keep this tool flexible for future use - both are just strings.  When the html output is dumped it will highlight in green for a status of “Success” and red for “Fail”.  This could easily be extended to highlight different colors for different status, do a regex instead of a straight match, etc.

Integrating Into Crontabs and Scripts

To integrate into my crontabs i created a simple “if” wrapper that assumes an return code of 0 is good and anything else is bad.  Scripts are wrapped the same way


<code>00 06 * * * if someCommandThatReturnsAnErrorCode; then statusboard update "My Thing" "Success"; else statusboard update "My Thing" "Fail"; fi</code>


tar czf /tmp/mytar.tar.gz /myfiles
if [ ! $TAR_RESULT ]
    statusboard update "Tar Operation" "Fail"
    statusboard update "Tar Operation" "Success"

The Code

Statusboard - https://github.com/zpeters/GoStatusBoard


Many improvements can (and probably should) be made to the code:

Thank you for reading I hope you’ve enjoyed and find this Go Statusboard helpful