Skip to content

Instantly share code, notes, and snippets.

@gardart
Last active August 29, 2015 14:13
Show Gist options
  • Save gardart/1dbc5800b977b39390c0 to your computer and use it in GitHub Desktop.
Save gardart/1dbc5800b977b39390c0 to your computer and use it in GitHub Desktop.
OneLiner: Send SQL query as mail with timestamp in the body
echo "USE dbname; SELECT COUNT(*) FROM votes;" | mysql --skip-column-names --user=dbuser --password=dbpassword dbname | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), "application:", "Number of votes:", $0;fflush(); }' | mail -s "Number of votes" mail@example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment