Systemd

Many Linux distributions (including Ubuntu) use systemd which manages system services.

(wikipedia.org)

In the following text an example service named vultrdata is used for illustrative purposes.

A service is defined in a file named like /etc/systemd/system/vultrdata.service. Unit files have a format like in this example:

[Unit]
Description=Vultr Instance Metadata Service
After=network.target

[Service]
User=vultrdata
WorkingDirectory=/opt/vultrdata
Restart=always
Environment=API_KEY=____________________________________
ExecStart=/opt/vultrdata/vultrdata --addr 10.1.2.3 --port 8888 --userdata

[Install]
WantedBy=multi-user.target

After creating the file in the /etc/systemd/system directory, issue this command to register it:

Then you can check the status:

Or start, stop, restart it:

You can enable or disable starting the unit/service on system startup:

You can see/tail all systemd logs, or just for your service (unit):

Last updated

Was this helpful?