Title: Auto restart bitcoind after crash on Ubuntu server Post by: tendemo on September 26, 2017, 12:02:29 PM 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
Title: Re: Auto restart bitcoind after crash on Ubuntu server Post by: mocacinno on September 26, 2017, 12:06:01 PM 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 Title: Re: Auto restart bitcoind after crash on Ubuntu server Post by: onnz423 on September 26, 2017, 12:16:49 PM 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? (https://bitcoin.stackexchange.com/questions/13795/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 (https://www.digitalocean.com/community/tutorials/how-to-use-a-simple-bash-script-to-restart-server-programs). However the bash script would go as something like this: Code: #!/bin/sh 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. Title: Re: Auto restart bitcoind after crash on Ubuntu server Post by: aleksej996 on September 26, 2017, 08:32:31 PM 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? (https://bitcoin.stackexchange.com/questions/13795/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 (https://www.digitalocean.com/community/tutorials/how-to-use-a-simple-bash-script-to-restart-server-programs). However the bash script would go as something like this: Code: #!/bin/sh 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. Title: Re: Auto restart bitcoind after crash on Ubuntu server Post by: tendemo on September 26, 2017, 08:47:13 PM A big thank you to all of you this seems to be what Im after Grateful for the explanations too. :)
Title: Re: Auto restart bitcoind after crash on Ubuntu server Post by: btctousd81 on September 29, 2017, 12:26:16 PM 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., Title: Re: Auto restart bitcoind after crash on Ubuntu server Post by: tendemo on September 29, 2017, 02:03:30 PM It definitely will help as well thanks.
|