systemctl restart xxx* does not restart inactive services

Bug #1627612 reported by Jake Yip
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Man pages of systemctl indicates that the start, restart, status takes in [PATTERN], which accepts wildcard.

However, for an inactive service, it does not work UNLESS --all is provided, which does not make sense for a command like restart. If one wants to restart only if service is active, there is the try-restart command.

To replicate

1. Stop a service. `systemctl stop sysstat.service`
2. Restart with wildcard. `systemctl restart sysstat*`
3. Check service status. It should still be inactive.
4. Restart with --all wildcard. `systemctl restart --all sysstat*`
5. Check again, service should have been started.

More logs below

root@notifications-m:~# systemctl status sysstat.service
● sysstat.service - LSB: Start/stop sysstat's sadc
   Loaded: loaded (/etc/init.d/sysstat; bad; vendor preset: enabled)
   Active: active (exited) since Mon 2016-09-26 16:22:02 AEST; 48min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3607 ExecStop=/etc/init.d/sysstat stop (code=exited, status=0/SUCCESS)
  Process: 3809 ExecStart=/etc/init.d/sysstat start (code=exited, status=0/SUCCESS)
    Tasks: 0
   Memory: 0B
      CPU: 0

Sep 26 16:22:02 notifications-m systemd[1]: Starting LSB: Start/stop sysstat's sadc...
Sep 26 16:22:02 notifications-m systemd[1]: Started LSB: Start/stop sysstat's sadc.
root@notifications-m:~# systemctl stop sysstat.service
root@notifications-m:~# systemctl status sysstat.service
● sysstat.service - LSB: Start/stop sysstat's sadc
   Loaded: loaded (/etc/init.d/sysstat; bad; vendor preset: enabled)
   Active: inactive (dead) since Mon 2016-09-26 17:10:16 AEST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8228 ExecStop=/etc/init.d/sysstat stop (code=exited, status=0/SUCCESS)
  Process: 3809 ExecStart=/etc/init.d/sysstat start (code=exited, status=0/SUCCESS)

Sep 26 16:22:02 notifications-m systemd[1]: Starting LSB: Start/stop sysstat's sadc...
Sep 26 16:22:02 notifications-m systemd[1]: Started LSB: Start/stop sysstat's sadc.
Sep 26 17:10:16 notifications-m systemd[1]: Stopping LSB: Start/stop sysstat's sadc...
Sep 26 17:10:16 notifications-m systemd[1]: Stopped LSB: Start/stop sysstat's sadc.
(reverse-i-search)`restar': systemctl ^Cstart --all ceilometer-agent-notification*
root@notifications-m:~# systemctl restart sysstat*
root@notifications-m:~# systemctl status sysstat.service
● sysstat.service - LSB: Start/stop sysstat's sadc
   Loaded: loaded (/etc/init.d/sysstat; bad; vendor preset: enabled)
   Active: inactive (dead) since Mon 2016-09-26 17:10:16 AEST; 16s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8228 ExecStop=/etc/init.d/sysstat stop (code=exited, status=0/SUCCESS)
  Process: 3809 ExecStart=/etc/init.d/sysstat start (code=exited, status=0/SUCCESS)

Sep 26 16:22:02 notifications-m systemd[1]: Starting LSB: Start/stop sysstat's sadc...
Sep 26 16:22:02 notifications-m systemd[1]: Started LSB: Start/stop sysstat's sadc.
Sep 26 17:10:16 notifications-m systemd[1]: Stopping LSB: Start/stop sysstat's sadc...
Sep 26 17:10:16 notifications-m systemd[1]: Stopped LSB: Start/stop sysstat's sadc.
root@notifications-m:~# systemctl restart --all sysstat*
root@notifications-m:~# systemctl status sysstat.service
● sysstat.service - LSB: Start/stop sysstat's sadc
   Loaded: loaded (/etc/init.d/sysstat; bad; vendor preset: enabled)
   Active: active (exited) since Mon 2016-09-26 17:10:39 AEST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8228 ExecStop=/etc/init.d/sysstat stop (code=exited, status=0/SUCCESS)
  Process: 8250 ExecStart=/etc/init.d/sysstat start (code=exited, status=0/SUCCESS)

Sep 26 17:10:39 notifications-m systemd[1]: Starting LSB: Start/stop sysstat's sadc...
Sep 26 17:10:39 notifications-m systemd[1]: Started LSB: Start/stop sysstat's sadc.

Revision history for this message
Martin Pitt (pitti) wrote :

Right. As the manpage states, inactive units are not considered: "Units which are not active and are not in a failed state usually are not loaded, and will not be matched by any pattern."

This isn't a behaviour that we can or want to change downstream, so closing. Thanks!

Changed in systemd (Ubuntu):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.