Adding Service In Background

in linux create a service file

sudo nano /lib/systemd/system/geth.service

Contents:
[Unit]

Description=Geth Full Node
After=network-online.target
Wants=network-online.target

[Service]

WorkingDirectory=/home/ubuntu
User=ubuntu
ExecStart=/usr/bin/geth --mainnet --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret /tmp/jwtsecret --syncmode full --http --http.api personal,eth,net,web3,txpool --http.corsdomain *
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

More service options for logs to go to a file instead of syslog:

StandardOutput=append:/home/user/stdout.log
StandardError=append:/root/stderr.log
StandardOutput=inherit

 

Then to use the service:

sudo systemctl enable geth
sudo systemctl start geth

For Logs:
sudo journalctl -f -u geth

If you want to modify the service file you must do:

sudo systemctl daemon-reload

then restart service

then watch logs with journal

Details
Updated: 12th June 2024

Play Blokr Now FREE!
blokr.io the web game where you can eat other blocks!