Skip to content

Instantly share code, notes, and snippets.

@scraperdragon
Last active December 14, 2015 09:19
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 scraperdragon/5064001 to your computer and use it in GitHub Desktop.
Save scraperdragon/5064001 to your computer and use it in GitHub Desktop.
Run command with no output if no error.
#!/bin/bash
x=$(date +%Y%m%dT%H%M%S)
mkdir -p ~/log
$@ > ~/log/$x 2>&1
error=$?
if [ $error != 0 ]
then
echo "Error code: $error"
cat ~/log/$x
curl --data "type=error" https://x.scraperwiki.com/api/status > /dev/null 2>&1
else
curl --data "type=ok" https://x.scraperwiki.com/api/status > /dev/null 2>&1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment