1

I have a "service" that originates from an /etc/init.d/XX script, and a systemd wrapper is generated for it. It doesn't autostart in any runlevel, and when I run systemctl --all or systemctl list-unit-files --all it doesn't show up in any list.

My hunch is that because it has no dependencies, hasn't been started, it isn't "loaded" into systemd (so not enabled, not loaded) so systemd doesn't list it.

Is there a way to get a full list of all possible services, even those not yet started and that aren't auto-started? Or do a systemctl search equivalent?

This related question only asks for a list of services that will be attempted at boot time.

The man page for systemctl under "--all" says

To list all units installed on the system, use the list-unit-files command instead

but these disabled units do not show up in the output of list-unit-files.

  • How you tried systemctl show XX? – muru May 8 at 20:38
  • systemctl show XX works, but I'm looking for a way to list "all the possible options for XX" as it were...even those that don't auto start, I added to the question. – rogerdpack May 9 at 21:16
2

OK I asked "the systemd guys" and they said in old versions it didn't list them all, despite the man page saying this:

   -a, --all
       When listing units, show all loaded units, regardless of their
       state, including inactive units. When showing unit/job/manager
       properties, show all properties regardless whether they are set or
       not.

       To list all units installed on the system, use the list-unit-files
       command instead.

Most of this didn't seem to actually happen with "my" systemd version systemd 219 on CentOS 6. But it seems fixed in newer versions of systemctl on Debian 9 which has version systemd 232

You can still control them like normal (status, start, stop) with the older systemd version if the init.d script does specify runlevels but is absent from all /etc/rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run initially on it) then the systemd-sysv-generator with older versions of systemd it doesn't [show up in the lists][2] if you run systemctl list-units --all etc. even though it's working fine and still controllable. Or if they're normal services but disabled they seem to also not show up in any lists, despite being still functional.

ref: https://lists.freedesktop.org/archives/systemd-devel/2019-May/042555.html

1

Are you running these commands as root? I believe that the list-unit-files command is exactly what you're looking for. It lists the unit files and not just the list of loaded services. I think you're likely looking at an issue with how your service is configured.

Maybe start by creating a dummy service and make sure it gets registered. Something that doesn't actually do anything. Then once that's working you can see how it differs from the service that isn't working. Or compare your service unit file with one of a simple service that is working.

  • 1
    There's a systemd SysV generator that translates init scripts to unit files, actually. – Jeff Schaller May 9 at 0:28
  • OK I did some tests, even using a dummy systemd service, and it appears that if "any" service is disabled (i.e. bound to no targets), then after a systemctl daemon-reload it no longer shows up in any lists...so it's not an issue exclusive to the systemd-sysv-generator methinks... – rogerdpack May 9 at 21:08

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.