Automation
ℹ
Time: 5 minutes
Having two terminals open is irritating. You want LND running in the background, just like bitcoind.
sudo nano /etc/systemd/system/lnd.servicePaste this in there.
[Unit]Description=Lightning Network DaemonRequires=bitcoind.serviceAfter=bitcoind.service[Service]User=ubuntuExecStart=/home/ubuntu/go/bin/lndPIDFile=/home/ubuntu/.lnd/lnd.pidRestart=alwaysTimeoutSec=180RestartSec=60[Install]WantedBy=multi-user.targetSave it again with Ctrl + X and confirm with Y.
The system should be notified of the new service and can then be started.
sudo systemctl enable lndsudo systemctl start lndIf you want to see if everything started up properly, run this:
systemctl status lndThe output should look something like this:
lnd.service - Lightning Network Daemon Loaded: loaded (/etc/systemd/system/lnd.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-01-15 11:19:18 UTC; 1min 24s ago Main PID: 73287 (lnd) Tasks: 9 (limit: 4203) CGroup: /system.slice/lnd.service └─73287 /home/ubuntu/go/bin/lndNov 25 17:45:10 raspberrypi systemd[1]: Started Lightning Network Daemon.Press q to exit the screen again.
If you want an overview of the status over multiple sessions, use this:
sudo journalctl -f -u lndTo finish up, you have to unlock LND with your password just like before. The nice thing is that now you don't have to have two terminals open. With lncli unlock everything is completed.