1

I wrote a long time ago a "dynamic" service unit /etc/systemd/system/[email protected]. I then enabled a few variations of the unit, such as [email protected] or [email protected].

And then I forgot what I enabled.

How can I list the units derived froma @.service entry?

I know that they exist because

  • they start services which I see running on my system
  • for those I remember, running systemctl show myunit@hello outputs correct information.

I though that systemctl or systemctl list-units --type service --all or systemctl list-unit-files | grep enabled would list them - but they do not. I do not see [email protected] in the output (despite show providing correct information)

These units are "oneshot" ones - the command in ExecStart does its job and exits (the type of unit is not set, I realize now - but it works so the default is OK)

The output of the show command closely matches the dynamic definition:

/etc/systemd/system # systemctl show docker-compose@domotique                                                                                                            root@srv
Type=simple
Restart=no
NotifyAccess=none
RestartUSec=100ms
TimeoutStartUSec=5s
TimeoutStopUSec=5s
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestampMonotonic=0
PermissionsStartOnly=no
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=0
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success
UID=[not set]
GID=[not set]
NRestarts=0
ExecMainStartTimestampMonotonic=0
ExecMainExitTimestampMonotonic=0
ExecMainPID=0
ExecMainCode=0
ExecMainStatus=0
ExecStartPre={ path=/usr/local/bin/docker-compose ; argv[]=/usr/local/bin/docker-compose -f /etc/docker/docker-compose-domotique.yaml pull --ignore-pull-failures ; ignore_errors=
ExecStart={ path=/usr/local/bin/docker-compose ; argv[]=/usr/local/bin/docker-compose -f /etc/docker/docker-compose-domotique.yaml up -d ; ignore_errors=no ; start_time=[n/a] ; s
Slice=system-docker\x2dcompose.slice
MemoryCurrent=[not set]
CPUUsageNSec=[not set]
TasksCurrent=[not set]
IPIngressBytes=18446744073709551615
IPIngressPackets=18446744073709551615
IPEgressBytes=18446744073709551615
IPEgressPackets=18446744073709551615
Delegate=no
CPUAccounting=no
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=infinity
IOAccounting=no
IOWeight=[not set]
StartupIOWeight=[not set]
BlockIOAccounting=no
BlockIOWeight=[not set]
StartupBlockIOWeight=[not set]
MemoryAccounting=no
MemoryLow=0
MemoryHigh=infinity
MemoryMax=infinity
MemorySwapMax=infinity
MemoryLimit=infinity
DevicePolicy=auto
TasksAccounting=yes
TasksMax=4915
IPAccounting=no
UMask=0022
LimitCPU=infinity
LimitCPUSoft=infinity
LimitFSIZE=infinity
LimitFSIZESoft=infinity
LimitDATA=infinity
LimitDATASoft=infinity
LimitSTACK=infinity
LimitSTACKSoft=8388608
LimitCORE=infinity
LimitCORESoft=0
LimitRSS=infinity
LimitRSSSoft=infinity
LimitNOFILE=4096
LimitNOFILESoft=1024
LimitAS=infinity
LimitASSoft=infinity
LimitNPROC=31230
LimitNPROCSoft=31230
LimitMEMLOCK=16777216
LimitMEMLOCKSoft=16777216
LimitLOCKS=infinity
LimitLOCKSSoft=infinity
LimitSIGPENDING=31230
LimitSIGPENDINGSoft=31230
LimitMSGQUEUE=819200
LimitMSGQUEUESoft=819200
LimitNICE=0
LimitNICESoft=0
LimitRTPRIO=0
LimitRTPRIOSoft=0
LimitRTTIME=infinity
LimitRTTIMESoft=infinity
WorkingDirectory=/etc/docker
OOMScoreAdjust=0
Nice=0
IOSchedulingClass=0
IOSchedulingPriority=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardInputData=
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SyslogLevel=6
SyslogFacility=3
LogLevelMax=-1
SecureBits=0
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap
AmbientCapabilities=
DynamicUser=no
RemoveIPC=no
MountFlags=
PrivateTmp=no
PrivateDevices=no
ProtectKernelTunables=no
ProtectKernelModules=no
ProtectControlGroups=no
PrivateNetwork=no
PrivateUsers=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=no
UtmpMode=init
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=0
LockPersonality=no
RuntimeDirectoryPreserve=no
RuntimeDirectoryMode=0755
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=0755
ConfigurationDirectoryMode=0755
MemoryDenyWriteExecute=no
RestrictRealtime=no
RestrictNamespaces=no
MountAPIVFS=no
KeyringMode=private
KillMode=control-group
KillSignal=15
SendSIGKILL=yes
SendSIGHUP=no
[email protected]
[email protected]
Requires=sysinit.target docker.service system-docker\x2dcompose.slice -.mount
Conflicts=shutdown.target
Before=shutdown.target
After=basic.target network.target system-docker\x2dcompose.slice sysinit.target -.mount systemd-journald.socket
RequiresMountsFor=/etc/docker
Description=docker compose startup for domotique
LoadState=loaded
ActiveState=inactive
SubState=dead
FragmentPath=/etc/systemd/system/[email protected]
UnitFileState=disabled
UnitFilePreset=enabled
StateChangeTimestampMonotonic=0
InactiveExitTimestampMonotonic=0
ActiveEnterTimestampMonotonic=0
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=no
AssertResult=no
ConditionTimestampMonotonic=0
AssertTimestampMonotonic=0
Transient=no
Perpetual=no
StartLimitIntervalUSec=10s
StartLimitBurst=5
StartLimitAction=none
FailureAction=none
SuccessAction=none
CollectMode=inactive



/etc/systemd/system # cat /etc/systemd/system/[email protected]                                                                                                    root@srv

[Unit]
Description=docker compose startup for %i
After=network.target
Requires=docker.service

[Service]
ExecStartPre=-/usr/local/bin/docker-compose -f /etc/docker/docker-compose-%i.yaml pull --ignore-pull-failures
ExecStart=/usr/local/bin/docker-compose -f /etc/docker/docker-compose-%i.yaml up -d
WorkingDirectory=/etc/docker

[Install]
WantedBy=multi-user.target

1 Answer 1

1

I'd suggest systemctl status myunit@*.service for example. See "glob patterns" in man systemctl.

If you are using a standard shell and there is a chance that files matching myunit@*.service exist in the current directory, then you may want to escape the * meta-charecter by using \* instead. It does not harm if you do it all the time, but it's a little bit of extra typing.

2
  • I would recomend to escape that asterisk ;) Otherwise it is expanded by shell. Do touch [email protected] in current working directory.
    – Jiri B
    Jun 15, 2022 at 10:56
  • While you are right, the likelihood of files named myunit@*.service in the current directory is quite low.
    – U. Windl
    Jun 17, 2022 at 6:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .