
인스턴스화된 시스템 서비스를 활성화할 때마다 동일한 인스턴스 지정자를 사용하여 두 개의 타이머를 활성화하고 싶습니다. 이것은 내 유닛 파일입니다[이메일 보호됨]좋다:
[Unit]
Description=Does something cool
Documentation=man:foo(1)
[Service]
Type=forking
ExecStart=/usr/bin/foo %i
PIDFile=%t/foo/foo.pid
StandardOutput=journal
[Install]
WantedBy=network-online.target
Also=bar1@%i.timer
Also=bar2@%i.timer
실행 결과:systemctl enable [email protected]
Failed to enable unit: Invalid argument
[Install] 섹션에서 인스턴스 지정자를 제거하고 이를 특정 인스턴스 이름(아래 표시된 대로)으로 바꾸면 제대로 작동합니다.
...
[email protected]
[email protected]
매뉴얼 페이지시스템 유닛(5)설명하다%나지정자는 설치 부분에서 설명했는데 무엇이 주어지나요?
The following specifiers are interpreted in the Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v.
답변1
이는 systemd의 버그인 것으로 보이며 섹션 Also
의 지시문에서 재현 됩니다 [Install]
.
그러나 해결 방법을 사용하여 동일한 기능을 제공할 수 있습니다.
파일이 있고 [email protected]
해당 유닛 파일이 필요하다고 가정해 보겠습니다. 대신 이 절을 지시어에 추가하세요 WantedBy
. .timer
먼저 등을 사용하여 장치를 활성화하십시오.systemctl enable [email protected]
[Install]
WantedBy=network-online.target bar1@%i.timer bar2@%i.timer
위 코드는 소켓 활성화를 통해 여러 mpd 서비스를 시작하기 위해 서비스 템플릿과 여러 소켓 파일을 사용하여 제대로 작동합니다.