Are you tired of your #[0]​ Bitcoin node being stuck in a restart loop if your peers.dat file gets corrupted? Instead of deleting it manually when you find out that this happened, do this:

1. Ssh into your node

2. Type “sudo su” to become root

3. Type “nano /etc/cron.hourly/corrupt-peers-delete”

4. Type the following script:

#!/bin/sh

CURRENT_DATE=$(date +%Y-%m-%d_%H-%M-%S)

echo "Running $CURRENT_DATE" > /home/umbrel/corrupt-peers-delete-cron.log

if (docker logs $(docker ps -aqf "name=bitcoin_bitcoind_1") -n 10 | grep "Invalid or corrupt peers.dat" >/dev/null 2>&1)

then

echo "Moving peers.dat" >> /home/umbrel/corrupt-peers-delete-cron.log

mv /home/umbrel/umbrel/app-data/bitcoin/data/bitcoin/peers.dat /home/umbrel/peers-corrupt-$CURRENT_DATE.dat

else

echo "Keeping peers.dat" >> /home/umbrel/corrupt-peers-delete-cron.log

fi

5. Type ctrl-x to exit nano, and choose Yes to save.

6. Make the script executable by typing: chmod +x /etc/cron.hourly/corrupt-peers-delete

7. exit the ssh

The cron job will run every hour and if the last logs of the Bitcoin docker cried about peers.dat being corrupt, the file will be moved to the home folder, so the Bitcoin node will construct a new peers.dat in the following restart (which happens automatically).

Good luck!

Reply to this note

Please Login to reply.

Discussion

No replies yet.