# Running und as a background service

If you intend to run your node as a Validator on any of the public networks, then you will most likely need to permanently run und as a background service (as opposed to manually running und start and leaving a terminal window/SSH session open).

This can easily be done using systemctl, and setting up an appropriate service configuration.

The following is a generic *nix guide, and may need adapting for your particular distribution.

Any text editor can be used to create the service configuration file, for example nano:

sudo nano /etc/systemd/system/und.service

At a minimum, the service configuration should contain the following, replacing USERNAME and FULL_PATH_TO with your own values:

[Unit]
Description=Unification Mainchain Validator Node

[Service]
User=USERNAME
Group=USERNAME
WorkingDirectory=/home/USERNAME
ExecStart=/usr/local/bin/und start --home /FULL_PATH_TO/.und_mainchain
Restart=on-failure
RestartSec=10s
LimitNOFILE=4096

[Install]
WantedBy=default.target

It is entirely possible to create a more sophisticated service definition should you desire.

Note

Also see: Using Cosmovisor with und: Quick Start for details on running und with cosmovisor.

Next, inform systemctl of the new service:

sudo systemctl daemon-reload
sudo systemctl enable und

The service can now be started:

sudo systemctl start und

and stopped:

sudo systemctl stop und

in the background.

Finally, you can monitor the log output for the service by running:

$ sudo journalctl -u und --follow