3/24/2015

Crontabs, Quick test for SSL websites

Sometimes you need to check the status or result of an SSL protected website after performing maintenance in an automated fashion, here's how to do that.

The typical crontab routine

MAILTO="john.willis@johnwillis.com, jwillis@johnwillis.com"
9 3 * * * /usr/bin/wget -O /dev/null https://www.johnwillis.com/index.cfm

Wget is a pretty flexible tool and if it is directed to [output] > [-O] the results of retrieving a website the details can be directed to devnull, while the alternate pipe results can be automatically emailed to the crontabs nominated recipient list.
--2015-03-24 03:09:01--  https://www.johnwillis.com/index.cfm 

Resolving www.johnwillis.com... 192.168.2.36 

Connecting to www.johnwillis.com|192.168.2.36|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: unspecified [text/html]
Saving to: `/dev/null'

     0K .......                                                59.1M=0s

2015-03-24 03:10:05 (59.1 MB/s) - `/dev/null' saved [8121]

 The really nice thing is the test is simple and quick to setup, not overly verbose, and does provide some measure of assurance that the connection was over an SSL protected connection (the certificate works) and was able to download the content to a file.

It could be refactored to perform additional testing or levels of detail, but essentially this would be sufficient for most quick glances at a mobile phone or early in the morning to be assured that a routine performed at night had not left a service in a nonfunctional state.