Finding bad systemctl definitions

systemd

I've just had to diagnose a fault that turned out to be because someone had edited a systemd definition (*.service) file and left an error behind. The result was that the service did not show up as failed but also did not run so my question is:

Is there a way to list all systemd units that have service definition errors?

As an example, here is the status of the job that failed:

localhost:~# systemctl status -l custom
● custom.service - Custom script
   Loaded: loaded (/usr/lib/systemd/system/custom.service; disabled; vendor 
preset: disabled)
   Active: inactive (dead)

Sep 12 16:00:25 localhost.localdomain systemd[1]: 
[/usr/lib/systemd/system/custom.service:20] Unknown section 'Path'. Ignoring.

I've tried listing dead services but there are many of them and most seem to be correct but just ended – what I want is to find the ones that have genuine errors such as this one.

Best Answer

systemd-analyze verify … will do some checks.

see man systemd-analyze for options.