Automatically restarting bitcoind five minutes after reboot on ubuntu

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

Marty

Posted 2019-11-03T13:58:18.237

Reputation: 19

1Don't you mean @reboot /path/to/bitcoind -daemon ...? You left out the command name.Nate Eldredge 2019-11-03T14:07:34.493

If you want to wait five minutes, you can do @reboot sleep 5m ; /path/to/bitcoind -daemon ...Nate Eldredge 2019-11-03T14:10:41.900

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 2019-11-03T18:33:42.677

If you just need it to shut down and start as your computer reboots, why not use the systemd service?Raghav Sood 2019-11-03T22:22:51.383

@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. https://unix.stackexchange.com/questions/146615/run-at-command-in-two-minutes-time

Jose Fonseca 2019-11-04T02:30:59.377

No answers