Create Custom Service (Daemon) | Systemd

Linux Apr 5, 2022

Create file:

sudo nano /etc/systemd/system/somename.service
[Unit]
Description=MyApp

[Service]
ExecStart=/usr/bin/somecommand start
ExecStop=/usr/bin/somecommand stop
Restart=always
User=nobody
# Note Debian/Ubuntu uses 'nogroup', RHEL/Fedora uses 'nobody'
Group=nogroup

WorkingDirectory=/home/ubuntu/SomeDir

[Install]
WantedBy=multi-user.target

Enable To Run On Boot:

sudo systemctl enable somename.service

Start, Stop, Status:

sudo systemctl start somename.service

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.