Here is bash script that auto transfers from hot to cold wallet upon threshhold met. Do you see issues? The idea is to run this via cron job at some interval and have the excess of funds transfered to cold wallet address.
So, I thought it will be easier to open source it so I can give it to the community and have it reviewed at the same time by more eyes.
It hasn't been tested yet. So, any issues you see? 

#!/usr/bin/bash
BITCOINCLI="/set/path/to/bitcoin-cli"
MINIMUM_TO_KEEP=0.1
RECEIVERS_ADDRESS=xxxyyyyzzzbitcoinaddress

echo bitcoin-cli executable is: $BITCOINCLI

tempOutput=$(mktemp)
tempOutputErr=$(mktemp)
#echo "$tempOutput"
#echo "$tempOutputErr"
"$BITCOINCLI" getbalance &gt; "$tempOutput" 2&gt; "$tempOutputErr"

#echo "output file:"
#cat "$tempOutput" 
#echo "Error file:"
#cat "$tempOutputErr"


outputsize=$(wc -c "$tempOutput" | cut -f 1 -d ' ')
if [ $outputsize -ge 1 ]; then
balance=$(cat ${tempOutput})
else
balance=XYZ
echo "Error: Could not connect to server. Or some other error while tring to find balance. " 
rm "$tempOutput" "$tempOutputErr"
exit
fi

echo Balance is "$balance"

sendamount=$(echo "            $balance  $MINIMUM_TO_KEEP  - p" | tr '\n\r' ' ' | dc   )

#echo comp = "$comp"  x
if [ "$sendamount" &gt; 0 ]; then
    echo "Balance is greater than the amount to be kept, which is $MINIMUM_TO_KEEP"
    echo Sending "$sendamount" BTC to the address "$RECEIVERS_ADDRESS"
    "$BITCOINCLI" sendtoaddress $RECEIVERS_ADDRESS $sendamount &gt; "$tempOutput" 2&gt; "$tempOutputErr"
    outputsize=$(wc -c "$tempOutputErr" | cut -f 1 -d ' ')
    if [ $outputsize -ge 1 ]; then
        echo Error while executing sendtoaddress. Could not send the amount. The error is:
        cat "$tempOutputErr"
    fi
else
    echo "Balance is less than $MINIMUM_TO_KEEP"
fi




rm "$tempOutput" "$tempOutputErr"
My thoughts, in no particular order:


Consider if you need a hot wallet at all. If you don't need to send funds, just accept them, you could probably use BIP32 to generate addresses. Downside is that this way is more complicated.
You should probably bail out of your script if bitcoin-cli produces any errors at all. If your Bitcoin node can't figure out its balance, then it won't be able to send a transaction.
It seems like you detect whether bitcoin-cli failed by 1) checking if it produced output, then 2) checking to make sure that it produced no errors. Why not just use its return codes? bitcoin-cli passes on any error codes.
Your script will tell Bitcoin to send to your cold wallet if you have any amount of extra Bitcoin, even a single satoshi. So, if some miscreant sent you an extra satoshi every time your script ran, it would generate a transaction and pay a fee. You should have a higher threshold, like

THRESHOLD=$(echo "$MINIMUM_TO_KEEP 0.01 * p" | dc)

I don't think that Bash can compare non-integers.

if [ "$sendamount" &gt; 0 ]; then


I'm not sure what this will do.

https://stackoverflow.com/questions/11237794/how-to-compare-two-decimal-numbers-in-bash-awk
Include this line before the rest of your script:

"$BITCOINCLI" getblocktemplate || exit


This will cause your script to bail out if your node is still synchronizing.
What's with this whitespace?

sendamount=$(echo "            $balance