Okay, I've got a really weird one for y’all: I have two machines with identical services running on them, nginx is specifically one of them, however, on one machine the following command lists nginx and nginx-prometheus-exporter, but on the other machi...
-
Okay, I've got a really weird one for y’all: I have two machines with identical services running on them, nginx is specifically one of them, however, on one machine the following command lists nginx and nginx-prometheus-exporter, but on the other machine, which is also running those, it doesn’t
systemctl --no-legend --no-pager list-units nginx* --type=service
but on the machine that doesn’t, systemctl status nginx shows it's running, active, and enabled.
What gives?
-
-
@[email protected] On the machine where it doesn't work, do you have anything starting with
nginx
in the current directory? If yes, use quotes. -
-
Emelia 👸🏻replied to Fiona last edited by [email protected]
@airtower I thought not, but on second look, yeah, that's it. But this isn't being invoked from command line, but the /etc/profile.d/010-banner.sh
-
@thisismissem
Try just nginx and see if it then shows up on both. If it does, then it might be a quoting thing. -
Emelia 👸🏻replied to Michael Boelen last edited by [email protected]
@mboelen yeah, that's the thing, just nginx alone wasn't even showing up:
Note: `systemctl status nginx` works
-
@thisismissem
In systemctl(1) under "start PATTERN..." it notes "Note that unit glob patterns expand to names of units currently in memory."Under "list units PATTERN..." is says "List units that systemd currently has in memory."
I'm not 100% sure what "in memory" means for systemd (how does that related to "loaded", for example) but perhaps run 'systemctl daemon-reload' which causes systemd to scan for unit-file changes?
-
@thisismissem if you add '.service' at the end? `systemctl list-units nginx*.service`
-
Emelia 👸🏻replied to Michael Boelen last edited by [email protected]
@mboelen works. Though I'm not sure why list-units needs the .service when status doesn’t, both take a pattern.
-
@virtuous_sloth @thisismissem so it can be that it one them needs a `daemon-reload` (or `reload-daemon`, I never knew which).
Or there's a big difference on the OSes or systemd versions?
-
@mdione @thisismissem
Usually if a unit file changes, if you try to stop/start etc. it warns you and does not do the operation.systemctl daemon-reload
tells systemd to rescan all unit files and update the configuration in memory, after which you can retry the start/stop operation.
When you create a new service by creating its new service file, you have to do that and I can see list-units ignoring it beforehand.
There are differences between versions but this is old behavior.
-
@virtuous_sloth @mdione these services have been in place for ages and we've definitely done daemon-reload