Author

Topic: Auto restart bitcoind after crash on Ubuntu server (Read 732 times)

newbie
Activity: 88
Merit: 0
September 29, 2017, 09:03:30 AM
#7
It definitely will help as well thanks.
sr. member
Activity: 434
Merit: 270
why not find why is your bitcoind is crashing a nd fixing that issue ?

you can always look in to log
check last 200 lines ,after crash, you will find you answer.

tail -n 200 ~/.bitcoin/debug.log

you can restart bitcoind after crash in multiple ways .

1) start bitcoind every minute cron.
only one session is allowed of bitcoind, so you dont have to check whether bitcoind is already running

simple cron command will work

* * * * * bitcoind

2) check if bitcoind process is running, if not then start using cronjobs.
you need a bash script to check if bitcoind is runnig, then run that script every minute using cronjob.


3) check if your bitcoind's port,( default . 8333) is open, if not, then start bitcoind.

hope this helps.,



newbie
Activity: 88
Merit: 0
A big thank you to all of you this seems to be what Im after Grateful for the explanations too. Smiley
sr. member
Activity: 490
Merit: 389
Do not trust the government
First of all you'll need to add bitcoind as a service (if you want, it will start every time that you start your computer): Ubuntu Linux — How do I start bitcoind as a service to run automatically?


You'll need to setup a crontab or something similar, since bitcoin daemon does not have such any kind of method for restarting the daemon after crash.
Here is basically a copy paste guide for restarting the daemon every time after crash How To Use a Simple Bash Script To Restart Server Programs.

However the bash script would go as something like this:
Code:
#!/bin/sh

ps auxw | grep bitcoind | grep -v grep > /dev/null

if [ $? != 0 ]
then
        /bitcoind start > /dev/null
fi

Im assuming that by root directory you mean that the bitcoind file is on the root folder which would be /.
I hope this is helpful, so far this kind of solutions is only one that i have found.

I somehow doubt that his bitcoind binary is in the root directory, so I would recommend running "which bitcoind" first to get the absolute path, but I don't think it is necessary, a relative one should be fine.
I think this solution is the easiest.
hero member
Activity: 840
Merit: 508
Make winning bets on sports with Sportsbet.io!
First of all you'll need to add bitcoind as a service (if you want, it will start every time that you start your computer): Ubuntu Linux — How do I start bitcoind as a service to run automatically?


You'll need to setup a crontab or something similar, since bitcoin daemon does not have such any kind of method for restarting the daemon after crash.
Here is basically a copy paste guide for restarting the daemon every time after crash How To Use a Simple Bash Script To Restart Server Programs.

However the bash script would go as something like this:
Code:
#!/bin/sh

ps auxw | grep bitcoind | grep -v grep > /dev/null

if [ $? != 0 ]
then
        /bitcoind start > /dev/null
fi

Im assuming that by root directory you mean that the bitcoind file is on the root folder which would be /.
I hope this is helpful, so far this kind of solutions is only one that i have found.

legendary
Activity: 3584
Merit: 5243
https://merel.mobi => buy facemasks with BTC/LTC
Hi I have a Bitcoin daemon running on an Ubuntu server and just noticed that it frequently crashes. How can I configure my server to auto restart the daemon after each crash . I launch my daemon using "bitcoind -daemon" at root directory. Thanks

if you edit your bitcoin.conf and add "daemon=1", you don't have to start it with the -daemon option

EDIT: found this nice link with other potential ways to do this: https://bitcoin.stackexchange.com/questions/13795/ubuntu-linux-how-do-i-start-bitcoind-as-a-service-to-run-automatically

EDIT2: removed the notion of the inittab, does not apply to ubuntu
newbie
Activity: 88
Merit: 0
Hi I have a Bitcoin daemon running on an Ubuntu server and just noticed that it frequently crashes. How can I configure my server to auto restart the daemon after each crash . I launch my daemon using "bitcoind -daemon" at root directory. Thanks
Jump to: