4

I want to figure out if a service is enabled or not.

With the SysV Init was easy. But with systemctl status <service name> is confusing and systemd is too complex to dig in.

Specifically, I try enabling with

# systemctl enable watchdog.service

but after reboot it's gives me this status:

# systemctl status watchdog.service
● watchdog.service - watchdog daemon
   Loaded: loaded (/lib/systemd/system/watchdog.service; static; vendor preset: enabled)
   Active: inactive (dead)

But I can't understand id it's enable but something happening, or if the enable service command failed.

At any moment, starting the service manually works fine:

# systemctl start watchdog.service
# systemctl status watchdog.service
● watchdog.service - watchdog daemon
   Loaded: loaded (/lib/systemd/system/watchdog.service; static; vendor preset: enabled)
   Active: active (running) since Qua 2016-12-21 04:03:26 BRST; 2s ago
  Process: 9111 ExecStart=/bin/sh -c [ $run_watchdog != 1 ] || exec /usr/sbin/watchdog $watchdog_options (code=exited, sta
  Process: 9109 ExecStartPre=/bin/sh -c [ -z "${watchdog_module}" ] || [ "${watchdog_module}" = "none" ] || /sbin/modprobe
 Main PID: 9115 (watchdog)
   CGroup: /system.slice/watchdog.service
           └─9115 /usr/sbin/watchdog

watchdog[9115]: int=1s realtime=yes sync=no soft=no mla=24 mem=0
watchdog[9115]: ping: no machine to check
watchdog[9115]: file: no file to check
watchdog[9115]: pidfile: no server process to check
systemd[1]: Started watchdog daemon.
watchdog[9115]: interface: no interface to check
watchdog[9115]: temperature: no sensors to check
watchdog[9115]: test=none(0) repair=none(0) alive=/dev/watchdog heartbeat=none to=root no_act=
watchdog[9115]: watchdog now set to 15 seconds
watchdog[9115]: hardware watchdog identity: Broadcom BCM2835 Watchdog timer
7

systemctl status tell us the unit is in status static:

# systemctl status watchdog.service
● watchdog.service - watchdog daemon
   Loaded: loaded (/lib/systemd/system/watchdog.service; static; vendor preset: enabled)
   Active: inactive (dead)

From man systemctl:

"static" | The unit file is not enabled, and has no provisions for enabling in the "[Install]" unit file section.

This basically means there is no [Install] section in the service file and thus you cannot enable it by systemctl enable. The way to enable such unit is to pull it into a dependency chain, i.e. make it being required or wanted by other units.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.