1

How can I run bitcoind automatically five minutes after restart?

So far I have crontab set up to reboot my computer every morning at 4AM (it runs into issues when it stays on for more than a couple days). I also have tried to use crontab to restart bitcoind on @reboot, but haven't had any success with that.

I am currently using Ubuntu 18.10, and bitcoind v0.18.0.0. Here is my current crontab:

0 4 * * * /sbin/shutdown -r +5
@reboot /usr/bin/bitcoind -daemon -conf=/home/<username>/.bitcoin/bitcoin.conf
5
  • 1
    Don't you mean @reboot /path/to/bitcoind -daemon ...? You left out the command name. Commented Nov 3, 2019 at 14:07
  • If you want to wait five minutes, you can do @reboot sleep 5m ; /path/to/bitcoind -daemon ... Commented Nov 3, 2019 at 14:10
  • Fixed to reflect actual crontab. I think I've diagnosed the problem: looking at debug.log, bitcoind can't start an http server on reboot because when my computer shuts down, it doesn't kill the original bitcoind process. As a result, when I start up, bitcoind doesn't have access to port 8332. As a result, I added the following to the first crontab entry: 0 4 * * * bitcoin-cli stop; /sbin/shutdown -r +5 I added the sleep 5m. Appears to do the job.
    – Marty
    Commented Nov 3, 2019 at 18:33
  • If you just need it to shut down and start as your computer reboots, why not use the systemd service? Commented Nov 3, 2019 at 22:22
  • @Marty When the computer shuts down the original bitcoind process does get killed. There's something else causing the issue. You may want to look at the at command and trigger it at startup. unix.stackexchange.com/questions/146615/… Commented Nov 4, 2019 at 2:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.