Eu encontrei uma boa solução usando ExecStartPost
.
% systemctl --user cat example@
# /home/joerg/.config/systemd/user/[email protected]
[Unit]
Description=Example of service farm; instance %i
[Service]
Type=simple
ExecStart=/bin/sleep 99999
ExecStartPost=/bin/sh -c 'test %i -gt 0 || exit 0 ; systemctl --no-block --user start %p@$((%i - 1))'
% systemctl --user start example@2
% systemctl --user status example.slice
● example.slice
Loaded: loaded
Active: active since Thu 2017-04-27 11:04:43 CEST; 27min ago
CGroup: /user.slice/user-1000.slice/[email protected]/example.slice
├─[email protected]
│ └─19423 /bin/sleep 99999
├─[email protected]
│ └─19420 /bin/sleep 99999
└─[email protected]
└─19417 /bin/sleep 99999