systemd – start,status,enable example

This is just a quick note to remind myself how to enable/disable services using systemd. In this example, I’m using ‘denyhosts’ service.

Check if a service is running.

# systemctl status denyhosts
denyhosts.service - SSH log watcher
   Loaded: loaded (/usr/lib/systemd/system/denyhosts.service; disabled)
   Active: inactive (dead)

Start a service and verify if it’s running:

# systemctl start denyhosts
# systemctl status denyhosts
denyhosts.service - SSH log watcher
   Loaded: loaded (/usr/lib/systemd/system/denyhosts.service; disabled)
   Active: active (running) since Thu 2014-07-17 01:44:29 EDT; 1min 25s ago
  Process: 15722 ExecStart=/usr/bin/denyhosts.py --daemon --config=/etc/denyhosts.conf (code=exited, status=0/SUCCESS)
  Process: 15719 ExecStartPre=/bin/rm -f /run/lock/subsys/denyhosts (code=exited, status=0/SUCCESS)
 Main PID: 19367 (denyhosts.py)
   CGroup: /system.slice/denyhosts.service
           └─19367 /usr/bin/python /usr/bin/denyhosts.py --daemon --config=/etc/denyhosts.conf

Jul 17 01:44:29 pidora.local systemd[1]: PID file /run/lock/subsys/denyhosts not readable (yet?) after start.
Jul 17 01:44:29 pidora.local systemd[1]: Started SSH log watcher.

Check if a ‘denyhosts’ service is enable or not:

# systemctl is-enabled denyhosts
disabled

Let’s enable it so it’ll start automatically on boot:

# systemctl enable denyhosts    
ln -s '/usr/lib/systemd/system/denyhosts.service' '/etc/systemd/system/multi-user.target.wants/denyhosts.service'

Ref: https://wiki.archlinux.org/index.php/systemd

Leave a Reply

Your email address will not be published. Required fields are marked *