Bitcoin Forum
December 08, 2021, 01:04:21 PM *
News: Latest Bitcoin Core release: 22.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Auto restart bitcoind after crash on Ubuntu server  (Read 659 times)
tendemo
Newbie
*
Offline Offline

Activity: 81
Merit: 0



View Profile
September 26, 2017, 12:02:29 PM
 #1

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
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1638968661
Hero Member
*
Offline Offline

Posts: 1638968661

View Profile Personal Message (Offline)

Ignore
1638968661
Reply with quote  #2

1638968661
Report to moderator
1638968661
Hero Member
*
Offline Offline

Posts: 1638968661

View Profile Personal Message (Offline)

Ignore
1638968661
Reply with quote  #2

1638968661
Report to moderator
mocacinno
Legendary
*
Online Online

Activity: 2520
Merit: 3637


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
September 26, 2017, 12:06:01 PM
 #2

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

onnz423
Hero Member
*****
Offline Offline

Activity: 840
Merit: 508


Make winning bets on sports with Sportsbet.io!


View Profile
September 26, 2017, 12:16:49 PM
 #3

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.


   ▄▄██████▄▄
  ████████████
███▄▄
 ██████████████▀▀▀██▄
████████████████   ▀██▄
████████████████     ▀██
██████████████       ██▌
██████████████        ▐██
██▌▀▀██████▀▀         ▐██
▐██                   ██▌
 ██▄                 ▄██
  ▀██▄             ▄██▀
    ▀██▄▄▄     ▄▄▄██▀
      ▀▀█████████▀▀





███████████████████████████
████████▀▀       ▀▀████████
█████▀   ▄ ▀███▀ ▄   ▀█████
████  ▄████▄ ▀ ▄████▄  ████
███  ▄ ▀███▀ ▄ ▀███▀ ▄  ███
██  ▄██ ▀▀ ▄███▄ ▀▀ ██▄  ██
██  █▀ ▄█ ███████ █▄ ▀█  ██
██   ▄███▄ █████ ▄███▄   ██
███  ████▀ ▄▄▄▄▄ ▀████  ███
████  ▀ ▄ ▀█████▀ ▄ ▀  ████
█████▄  ▀▀▄ ███ ▄▀▀  ▄█████
████████▄▄       ▄▄████████
███████████████████████████





█▀▀











█▄▄
▀▀█











▄▄█
█▀▀











█▄▄
▀▀█











▄▄█
aleksej996
Sr. Member
****
Offline Offline

Activity: 490
Merit: 343


Do not trust the government


View Profile
September 26, 2017, 08:32:31 PM
 #4

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.
tendemo
Newbie
*
Offline Offline

Activity: 81
Merit: 0



View Profile
September 26, 2017, 08:47:13 PM
 #5

A big thank you to all of you this seems to be what Im after Grateful for the explanations too. Smiley
btctousd81
Sr. Member
****
Offline Offline

Activity: 434
Merit: 258


View Profile WWW
September 29, 2017, 12:26:16 PM
 #6

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.,




tendemo
Newbie
*
Offline Offline

Activity: 81
Merit: 0



View Profile
September 29, 2017, 02:03:30 PM
 #7

It definitely will help as well thanks.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!