Time: 5 minutes
Instead of needing to start Bitcoin Core manually, it would be nice to start it automatically. This could be useful after restarting your Pi or if bitcoind crashes for some reason. Linux has systemd services for automated tasks like that. Before you start automating, please make sure Bitcoin Core (bitcoind) is turned off. You can do it this way:
When bitcoind is turned off we can start creating the service.
sudo nano /etc/systemd/system/bitcoind.service
Paste this in there.
Save the file with
Crtl + X and confirm with
The system needs to be notified about the new service which can afterwards be started.
sudo systemctl enable bitcoind
sudo systemctl start bitcoind
If you'd want to see whether it started correctly, run the command below. Note: it can take a minute or so before you get a response that tells you everything is alright.
systemctl status bitcoind
It could be possible things don't work from the get-go. That would be the case if your output doesn't looks like this:
● bitcoind.service - Bitcoin DaemonLoaded: loaded (/etc/systemd/system/bitcoind.service; enabled; vendor preset: enabled)Active: active (running) since Fri 2022-01-14 12:20:53 UTC; 2s agoMain PID: 40483 (bitcoind)Tasks: 12 (limit: 4203)CGroup: /system.slice/bitcoind.service└─40483 /usr/local/bin/bitcoindJan 14 12:20:53 ubuntu systemd: Started Bitcoin Daemon.Jan 14 12:20:53 ubuntu bitcoind: Bitcoin Core starting
Try the same command another few times, because it could take up to a minute before bitcoind is started correctly by the service.
If you'd like to see an overview of the status over multiple sessions, use this:
sudo journalctl -f -u bitcoind