Checking bitcoin sync status on command line

If anyone runs plane bitcoind (on *nux systems), as in any other case, it will take a while to sync all the blocks from the network. The question is, how can you see what is the current status without using some fancy UI client?

The idea is simple:

  1. Get current local block count
  2. Get the blockcount from blockchain
  3. The difference is what you want

So, one of the possibilities is to create a simple bash script:

Note: when we run bitcoind command we must provide a reference to a valid bitcoin.conf file. So just simply adjust it to the correct path on your system.

Now let’s run it and get the result

 

Happy syncing :)

Posted in Bitcoin Tagged with: ,
  • http://jondrews.com/ Jon Drews

    Had to make a few changes to get this to work (using CentOS 6)

    #!/bin/bash

    blockCount=$(bitcoin-cli getblockcount)
    blockChain=$(curl https://blockchain.info/q/getblockcount 2>/dev/null)
    blockDiff=$((blockChain-$blockCount))
    if [[ “$blockDiff” = 0 ]];
    then
    echo “up to date”
    else
    echo “$blockDiff blocks behind”
    fi
    exit 0