search by tags

for the user

adventures into the land of the command line

Using systemctl to manage systemd services

The newest of the init things, found on debian and fedora. To create your own systemd service, (I’m using mongodb as an example), create a file in this directory:

$ sudo vim /lib/systemd/system/mongod.service

Add in something like this. Bear in mind this is a VERY simple example:

Description=Mongo is a scalable, document-oriented database.

ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf


Verify if systemd knows about the service and what it’s boot status is.

$ sudo systemctl list-unit-files --type=service
mongod.service             disabled

Enable it to start on reboot.

$ sudo systemctl enable mongod.service

Check again that systemd has it updated.

$ sudo systemctl list-unit-files --type=service
mongod.service             enabled

You can manage the service with commands like this.

$ sudo systemctl status mongod
$ sudo systemctl stop mongod
$ sudo systemctl start mongod
$ sudo systemctl restart mongod