Skip to content

Instantly share code, notes, and snippets.

@hasantayyar
Last active August 1, 2017 07:08
Show Gist options
  • Save hasantayyar/d5926f17a32ae6ca0f81914689684a4a to your computer and use it in GitHub Desktop.
Save hasantayyar/d5926f17a32ae6ca0f81914689684a4a to your computer and use it in GitHub Desktop.
### your_cronjob.sh ####
btc=$(curl -s http://api.coindesk.com/v1/bpi/currentprice.json | python -c "import json, sys; print(int(json.load(sys.stdin)['bpi']['USD']['rate'].replace(',','').split('.')[0] ))")
ALERT_BTC=3000
if [ $(($btc + 1)) -gt $ALERT_BTC ];
then
echo "btc is greater than $ALERT_BTC";
push "BTC value is greater then $ALERT_BTC"
fi;

to ~/.bashrc or ~/.zshrc

push(){
    echo "Sending message to pushover. $1"
    curl https://api.pushover.net/1/messages.json -X POST \
        --data "token=xxxxxx&user=xxxxxx&message=$1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment