I'm trying to get /usr/bin/bitcoind to start on boot but without success.

I have this script on /etc/init/bitcoind.conf

description "bitcoind" start on filesystem stop on runlevel [!2345] oom never expect daemon respawn respawn limit 10 60 # 10 times in 60 seconds script user=andre home=/home/$user cmd=/usr/bin/bitcoind pidfile=$home/.bitcoin/bitcoind.pid # Don't change anything below here unless you know what you're doing [[ -e $pidfile && ! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile [[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile --starta $cmd -b -m end script 

After creating this script I've run the command: sudo initctl reload-configuration

When I restart Ubuntu the "bitcoind" does not start. I only can start "bitcoind" running manually the command:

sudo start bitcoind 

Any clues on how to start "bitcoind" on boot?

1

2 Answers

So I finally got things working on an Ubuntu 14.04 server. Here's what the final, working /etc/init/bitcoind.conf looks like:

description "bitcoind" start on filesystem stop on runlevel [!2345] oom score -500 expect fork respawn respawn limit 10 60 # 10 times in 60 seconds script user=bitcoind home=/home/$user cmd=$home/bin/bitcoind pidfile=$home/bitcoind.pid # Don't change anything below here unless you know what you're doing [[ -e $pidfile && ! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile [[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile -m --startas $cmd end script 

It was basically just a lot of guess and check work to get this working. Here's the important bit:

expect fork 

Essentially, this is telling upstart how many times the target process will be forked while starting. If you tell it wrong, it'll hang while starting. Read here for the specifics on this.

One other, minor change:

oom score -500 

Instead of:

oom never 

Not such a critical change, but after reading about upstart a bit and from seeing a suggestion in a stackoverflow answer, oom never should almost never be used. See here for more info.

This is what I did.

Check the file /etc/rc.local with cat /etc/rc.local

You will see something like this

#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. 

Then just add this line

bitcoind -daemon 

You can execute bitcoind with the options -datadir=/path/to/data or -conf=/path/to/bitcoin.conf if you need it.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy