Skip to content

Instantly share code, notes, and snippets.

@mrizvic
Created January 19, 2017 11:28
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 mrizvic/ac8b7daa6af3fed948b37820e901a9b4 to your computer and use it in GitHub Desktop.
Save mrizvic/ac8b7daa6af3fed948b37820e901a9b4 to your computer and use it in GitHub Desktop.
cronjob for periodic report in HTML and cowsay format
#!/usr/bin/env bash
WORKFILE=/tmp/myreport.out
cat <<EOF > $WORKFILE
From: username <username@localhost.localdomain>
To: username@localhost.localdomain
Subject: your html report
Content-Type: text/html; charset="us-ascii"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title></title>
</head>
<body>
<pre>
$(mysql -te "SELECT this FROM that WHERE something LIKE 'this%';" | cowsay -n )
</pre>
</body>
</html>
EOF
sendmail username@localhost.localdomain < $WORKFILE
unlink $WORKFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment