Skip to content

Instantly share code, notes, and snippets.

@vidul-nikolaev-petrov
Created August 18, 2014 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vidul-nikolaev-petrov/469c97837ed71d79ae57 to your computer and use it in GitHub Desktop.
Save vidul-nikolaev-petrov/469c97837ed71d79ae57 to your computer and use it in GitHub Desktop.
email HTTP response code
# sample usage (crontab):
# 55 11 * * * /home/monitor/bin/email_http_response_code.pl
my $email = 'YOUR EMAIL ADDRESS'; #example: root@google.com
my $website = 'YOUR WEBSITE URL'; #example: http://google.com
my $date_now = localtime;
my $result_http_code = `curl -sL -w '%{http_code} %{url_effective}' '$website' -o /dev/null`;
$result_http_code =~ s/(\S+)$/($1)/;
`echo "$date_now" | mail -s "HTTP response code: $result_http_code" "$email"`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment